Search code examples
c#.netblazorgithub-actionsmaui

.NET 8 GitHub Actions gives "error NETSDK1112: The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded" in Blazor Hybrid Build


I'm trying to build Blazor Hybrid project in Github Actions. Here is my yml file,

name: build

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build-and-test:
    runs-on: windows-latest
    steps:
      # Checkout the code
      - uses: actions/[email protected]

      # Install .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 8.0.x
          
      # Install dotnet buildtools workload
      - name: Install .NET Build Tools
        run: dotnet workload install maui macos ios wasm-tools

      # Restore Dependencies
      - name: Restore dependencies
        run: dotnet restore
        
      # Build Blazor
      - name: Build Blazor
        run: dotnet build ./Web/Web.csproj --configuration Release --no-restore

      # Build Android
      - name: Build Android
        run: dotnet build ./MAUI/MAUI.csproj -f net8.0-android --configuration Release --no-restore

      # Build IOS
      - name: Build IOS
        run: dotnet build ./MAUI/MAUI.csproj -f net8.0-ios --configuration Release --no-restore

      # Build Windows
      - name: Build Windows
        run: dotnet build ./MAUI/MAUI.csproj -f net8.0-windows10.0.19041.0 -p:RuntimeIdentifierOverride=win-x64 --configuration Release --no-restore

      # Build MacCatalyst
      - name: Build MacCatalyst
        run: dotnet build ./MAUI/MAUI.csproj -f net8.0-maccatalyst --configuration Release --no-restore

Then Build Windows step fails and gives the following error:

Run dotnet build ./MAUI/MAUI.csproj -f net8.0-windows10.0.19041.0 -p:RuntimeIdentifierOverride=win-x64 --configuration Release --no-restore
MSBuild version 17.9.4+90725d08d for .NET
Error: C:\Program Files\dotnet\sdk\8.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1112: The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'. [D:\a\BlazorHybrid\BlazorHybrid\MAUI\MAUI.csproj::TargetFramework=net8.0-windows10.0.19041.0]
Build FAILED.
Error: C:\Program Files\dotnet\sdk\8.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1112: The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'. [D:\a\BlazorHybrid\BlazorHybrid\MAUI\MAUI.csproj::TargetFramework=net8.0-windows10.0.19041.0]
    0 Warning(s)
    1 Error(s)
Time Elapsed 00:00:00.69
Error: Process completed with exit code 1.

I have tried specifying RuntimeIdentifier as win-x64 or win10-x64. But still the build fails when building for Windows TFM. Not able to find any proper docs on this. Here is the repo link. Please can you assist me on what I'm missing?


Solution

  • Finally, I understood what is going on wrong here. I need to remove the --no-restore flag from the build command. So the final command looks like,

    dotnet build ./MAUI/MAUI.csproj -f net8.0-windows10.0.19041.0 -p:RuntimeIdentifierOverride=win10-x64 --configuration Release

    Source:

    .NET Conf 2023 session

    sample GitHub and Azure DevOps build pipelines