Skip to content

GitHub Actions fails with .NET 9 when using global-json-file #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 5 tasks
hongbo-miao opened this issue Dec 4, 2024 · 2 comments
Closed
2 of 5 tasks

GitHub Actions fails with .NET 9 when using global-json-file #563

hongbo-miao opened this issue Dec 4, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@hongbo-miao
Copy link

hongbo-miao commented Dec 4, 2024

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:

  • Ubuntu
  • macOS
  • Windows

Runner type

  • Hosted
  • Self-hosted

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/[email protected]
      - name: Set up NuGet
        uses: nuget/[email protected]
        with:
          nuget-version: 6.12.1
      - name: Set up .NET Core
        uses: actions/[email protected]
        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/[email protected]
      - name: Set up NuGet
        uses: nuget/[email protected]
        with:
          nuget-version: 6.12.1
      - name: Set up .NET Core
        uses: actions/[email protected]
        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

@hongbo-miao hongbo-miao added bug Something isn't working needs triage labels Dec 4, 2024
@hongbo-miao hongbo-miao changed the title GitHub Actions fails to .NET 9.0 when use global-json-file GitHub Actions fails to .NET 9 when use global-json-file Dec 4, 2024
@priya-kinthali
Copy link

Hello @hongbo-miao 👋,
Thank you for reporting this issue. We will investigate it and get back to you as soon as we have some feedback.

@mahalakshmi-rekadi mahalakshmi-rekadi self-assigned this Dec 4, 2024
@hongbo-miao hongbo-miao changed the title GitHub Actions fails to .NET 9 when use global-json-file GitHub Actions fails with .NET 9 when using global-json-file Dec 6, 2024
@hongbo-miao
Copy link
Author

hongbo-miao commented Dec 9, 2024

I think this is related to the issue dotnet/sdk#45290 and has been fixed and will work in the coming new 9.0.2xx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants