Skip to content

Commit bc0c4f5

Browse files
PetSerAlpisolofin
authored andcommitted
Use current dotnet host instead of global (belav#1387)
Use current `dotnet` binary from `DOTNET_HOST_PATH` instead of just `dotnet`. Reasons: 1. Global (in `PATH`) may not exist (when used _Binaries_, but not _Installers_). 2. Global can have different runtime version. 3. Consistent with outer tools (`csc` for example). https://github.com/dotnet/roslyn/blob/324fd25331c969cd742ba68eee09ffd4b6fd29e3/src/Compilers/Shared/RuntimeHostInfo.cs#L61-L64 4. It is documented to be used for that purpose. https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_host_path
1 parent 76cfd51 commit bc0c4f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Src/CSharpier.MsBuild/build/CSharpier-Config.MsBuild.targets

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' == '' and $([MSBuild]::VersionGreaterThanOrEquals($(NETCoreSdkVersion), '8.0'))">net8.0</CSharpier_FrameworkVersion>
55
<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' == ''" Label="Fallback">net8.0</CSharpier_FrameworkVersion>
66
<CSharpierDllPath>$(MSBuildThisFileDirectory)../tools/csharpier/$(CSharpier_FrameworkVersion)/dotnet-csharpier-config.dll</CSharpierDllPath>
7+
<CSharpier_dotnet_Path Condition="'$(CSharpier_dotnet_Path)' == ''">$(DOTNET_HOST_PATH)</CSharpier_dotnet_Path>
8+
<CSharpier_dotnet_Path Condition="'$(CSharpier_dotnet_Path)' == ''">dotnet</CSharpier_dotnet_Path>
79
<CSharpierArgs Condition="'$(CSharpier_Check)' == 'true'">$(CSharpierArgs) --check</CSharpierArgs>
810
<CSharpierArgs Condition="'$(CSharpier_LogLevel)' != ''">$(CSharpierArgs) --loglevel $(CSharpier_LogLevel)</CSharpierArgs>
911
<FirstTargetFramework Condition=" '$(TargetFrameworks)' == '' ">$(TargetFramework)</FirstTargetFramework>
@@ -23,7 +25,7 @@
2325
StdOutEncoding="utf-8"
2426
StdErrEncoding="utf-8"
2527
IgnoreExitCode="true"
26-
Command="dotnet &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings &quot;$(MSBuildProjectDirectory)&quot; &gt; $(NullOutput) " />
28+
Command="&quot;$(CSharpier_dotnet_Path)&quot; exec &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings &quot;$(MSBuildProjectDirectory)&quot; &gt; $(NullOutput) " />
2729
</Target>
2830

2931
<!-- getting this to run a single time for projects that target multiple frameworks requires all of this

0 commit comments

Comments
 (0)