Description
I found after upgrading to .NET 9, using global-json-file will cause following steps fail to find dotnet.
For old .NET 8, global-json-file way works well.
Platform:
Runner type
Repro steps
Experiment 1 (Succeed when hard code dotnet-version)
When hard code SDK version, and it can succeed:
lint-csharp-national-instruments-veristand-zeromq-bridge:
name: C# (national-instruments-veristand-zeromq-bridge)
needs: detect-changes
if: ${{ needs.detect-changes.outputs.national-instruments-veristand-zeromq-bridge == 'true' }}
runs-on: windows-2022
environment: test
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Set up NuGet
uses: nuget/setup-nuget@v2.0.1
with:
nuget-version: 6.12.1
- name: Set up .NET Core
uses: actions/setup-dotnet@v4.1.0
with:
dotnet-version: 9.0.101 # <---
- name: Install dependencies
working-directory: hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge
run: |
nuget restore VeriStandZeroMQBridge.sln
dotnet tool restore
- name: Lint C# (format)
working-directory: hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge
run: |
dotnet format VeriStandZeroMQBridge.sln --verify-no-changes
Experiment 2 (Failed when read dotnet-version from global-json-file)
When use global-json-file, correct version dotnet got installed successfully, however, in next step, when try to use dotnet, it failed:
lint-csharp-national-instruments-veristand-zeromq-bridge:
name: C# (national-instruments-veristand-zeromq-bridge)
needs: detect-changes
if: ${{ needs.detect-changes.outputs.national-instruments-veristand-zeromq-bridge == 'true' }}
runs-on: windows-2022
environment: test
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Set up NuGet
uses: nuget/setup-nuget@v2.0.1
with:
nuget-version: 6.12.1
- name: Set up .NET Core
uses: actions/setup-dotnet@v4.1.0
with:
global-json-file: hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge/global.json # <---
- name: Install dependencies
working-directory: hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge
run: |
nuget restore VeriStandZeroMQBridge.sln
dotnet tool restore
- name: Lint C# (format)
working-directory: hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge
run: |
dotnet format VeriStandZeroMQBridge.sln --verify-no-changes
hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge/global.json
{
"sdk": {
"version": "9.0.101"
}
}
When try to use dotnet, it failed with:
Unhandled exception: System.Exception: The build host could not be found at 'C:\Program Files\dotnet\sdk\9.0.101\DotnetTools\dotnet-format\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe'
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.AssertBuildHostExists(String buildHostPath)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetDotNetFrameworkBuildHostPath()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.CreateDotNetFrameworkBuildHostStartInfo()
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostWithFallbackAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectFileInfosAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectInfosFromPathAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadAsync(CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenSolutionAsync(String solutionFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceLoader.LoadAsync(String solutionOrProjectPath, WorkspaceType workspaceType, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
Expected behavior
I expect using global-json-file should also succeed for new .NET 9
Actual behavior
It failed when use global-json-file for .NET 9
Description
I found after upgrading to .NET 9, using
global-json-filewill cause following steps fail to finddotnet.For old .NET 8,
global-json-fileway works well.Platform:
Runner type
Repro steps
Experiment 1 (Succeed when hard code
dotnet-version)When hard code SDK version, and it can succeed:
Experiment 2 (Failed when read
dotnet-versionfrom global-json-file)When use
global-json-file, correct version dotnet got installed successfully, however, in next step, when try to usedotnet, it failed:hardware-in-the-loop/national-instruments/veristand/VeriStandZeroMQBridge/global.json
{ "sdk": { "version": "9.0.101" } }When try to use
dotnet, it failed with:Expected behavior
I expect using
global-json-fileshould also succeed for new .NET 9Actual behavior
It failed when use
global-json-filefor .NET 9