Skip to content

Commit

Permalink
respect DOTNET_HOST_PATH if set
Browse files Browse the repository at this point in the history
The variable `DOTNET_HOST_PATH` is used by `dotnet` to expose the path to the current invocation of the host. Tools should use it when making nested calls.

<https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_host_path>
  • Loading branch information
iwillspeak authored and adamralph committed Aug 15, 2024
1 parent e68e5f0 commit b18a7a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MinVer/build/MinVer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<NoWarn>$(NoWarn);NU5105</NoWarn>
</PropertyGroup>

<PropertyGroup>
<DotNetPath>$(DOTNET_HOST_PATH)</DotNetPath>
<DotNetPath Condition=" '$(DotNetPath)' == '' ">dotnet</DotNetPath>
</PropertyGroup>

<Target Name="_MinVerClean" BeforeTargets="Clean" DependsOnTargets="MinVer" Condition="'$(GeneratePackageOnBuild)' == 'true'" />

<Target Name="MinVer" BeforeTargets="BeforeCompile;GetAssemblyVersion;CoreCompile" Condition="'$(DesignTimeBuild)' != 'true' AND '$(MinVerSkip)' != 'true'">
Expand Down Expand Up @@ -51,7 +56,7 @@
</ItemGroup>
<CacheGet Key="@(MinVerInputs->'%(Identity)', ' ')"><Output TaskParameter="Value" PropertyName="MinVerVersion" /></CacheGet>
<Message Condition="'$(MinVerVersion)' != ''" Importance="$(MinVerDetailed)" Text="MinVer: Using cached MinVerVersion $(MinVerVersion)" />
<Exec Condition="'$(MinVerVersion)' == ''" Command="dotnet &quot;$(MSBuildThisFileDirectory)bin/$(MinVerTargetFramework)/MinVer.dll&quot; &quot;$(MSBuildProjectDirectory)&quot; @(MinVerInputs->'%(Identity)', ' ')" ConsoleToMSBuild="true" StandardOutputImportance="Low" >
<Exec Condition="'$(MinVerVersion)' == ''" Command="&quot;$(DotNetPath)&quot; &quot;$(MSBuildThisFileDirectory)bin/$(MinVerTargetFramework)/MinVer.dll&quot; &quot;$(MSBuildProjectDirectory)&quot; @(MinVerInputs->'%(Identity)', ' ')" ConsoleToMSBuild="true" StandardOutputImportance="Low" >
<Output TaskParameter="ConsoleOutput" ItemName="MinVerConsoleOutput" />
</Exec>
<ItemGroup Condition="'$(MinVerVersion)' == ''" >
Expand Down

0 comments on commit b18a7a1

Please sign in to comment.