Nitrox.Discovery.MSBuild 0.1.1

dotnet add package Nitrox.Discovery.MSBuild --version 0.1.1
                    
NuGet\Install-Package Nitrox.Discovery.MSBuild -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nitrox.Discovery.MSBuild" Version="0.1.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nitrox.Discovery.MSBuild" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Nitrox.Discovery.MSBuild">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nitrox.Discovery.MSBuild --version 0.1.1
                    
#r "nuget: Nitrox.Discovery.MSBuild, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nitrox.Discovery.MSBuild@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nitrox.Discovery.MSBuild&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Nitrox.Discovery.MSBuild&version=0.1.1
                    
Install as a Cake Tool

Nitrox.Discovery

NuGet

Discovers the path to an installed game from a given game name. Supports the most popular game stores and on both Windows and Linux.

Use with MSBuild (minimized setup)

<Target Name="FindGameAndIncludeReferences" BeforeTargets="ResolveAssemblyReferences" Condition="'$(_NitroxDiscovery_TaskAssembly)' != ''">
    <DiscoverGame GameName="Subnautica"> 
        <Output TaskParameter="GamePath" PropertyName="GameDir" />
    </DiscoverGame>
    <Error Condition="'$(GameDir)' == ''" Text="Failed to find the game 'Subnautica' on your machine" />

    
    <ItemGroup>
        <Reference Include="MyGameDll">
            <HintPath>$(GameDir)\bin\MyGameDll.dll</HintPath>
        </Reference>
    </ItemGroup>
</Target>

Condition="'$(_NitroxDiscovery_TaskAssembly)' != ''" is needed so Visual Studio can still load Nuget packages without requiring DiscoverGame task to exist!

These options are available for DiscoverGame task

https://github.com/SubnauticaNitrox/Nitrox.Discovery/blob/7c018aa3fd9f05ad012fe91ccb8a535ffbd5b2c5/Nitrox.Discovery.MSBuild/DiscoverGame.cs#L21-L47

<Target Name="FindGameAndIncludeReferences" BeforeTargets="ResolveAssemblyReferences" Condition="'$(_NitroxDiscovery_TaskAssembly)' != ''">
    <PropertyGroup>
        
        <GameName>MY_GAME</GameName>
    </PropertyGroup>
    <DiscoverGame GameName="$(GameName)">
        <Output TaskParameter="GamePath" PropertyName="GameDir" />
    </DiscoverGame>
    <Error Condition="'$(GameDir)' == ''" Text="Failed to find the game '$(GameName)' on your machine" />
    <PropertyGroup>
        <GameDir>$(GameDir)\</GameDir>
    </PropertyGroup>
    
    <Message Importance="high" Text="Game found at: '$(GameDir)'" />

    
    <ItemGroup>
        <Reference Include="MyGameDll">
            <HintPath>$(GameDir)bin\MyGameDll.dll</HintPath>
        </Reference>
    </ItemGroup>
</Target>

You can append other references on a per project basis like this

<Target Name="MoreGameReferences" AfterTargets="FindGameAndIncludeReferences">
    <ItemGroup>
        <Reference Include="SomeOtherGameDll">
            <HintPath>$(GameDir)bin\SomeOtherGameDll.dll</HintPath>
        </Reference>
    </ItemGroup>
</Target>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Nitrox.Discovery.MSBuild:

Repository Stars
SubnauticaNitrox/Nitrox
An open-source, multiplayer modification for the game Subnautica.