Search code examples
c#.netazure-pipelinesmsix

.NET 8 in Azure DevOps gives "Error NETSDK1112: The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded"


I have upgraded an MSIX WPF app to .NET 8 from .NET 7, and it runs fine on my own computer. But when I try to build it in Azure DevOps, I get the errors:

C:\agent\_work\_tool\dotnet\sdk\8.0.100\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'.

C:\agent\_work\_tool\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): Error NETSDK1112: The runtime pack for Microsoft.WindowsDesktop.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'.

I get the same error on both my on-premise build server and when using a hosted agent.

I used these tasks to install and verify .NET 8 on the machines:

- task: UseDotNet@2
  inputs:
    version: '8.x'

- task: PowerShell@2
  displayName: 'Check .NET Version and SDKs'
  inputs:
    targetType: 'inline'
    script: |    
        dotnet --version
        dotnet --list-sdks
        dotnet --list-runtimes

But it made no difference.

The project file contains this (I have not changed it since .NET 7)

 <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
 <RuntimeIdentifier>win-x64</RuntimeIdentifier>

I build the project using this task:

trigger:
 branches:
   include:
   - master

stages:
- stage: Build

  jobs:  

  - job: Build
    displayName: "Build app and installer"
    pool:
      vmImage: 'windows-latest'

    steps:

    - task: VSBuild@1
      inputs:
        solution: 'TestApp.sln'
        vsVersion: 'latest'
        platform: 'x64'
        configuration: 'Release' 
        msbuildArchitecture: 'x64'
        msbuildArgs: ''

NEW: Minimal repro project: https://github.com/tripleacoder/MSIXTestApp/


Solution

  • I can reproduce the same issue.

    enter image description here

    To solve this issue, you can change the <RuntimeIdentifier>win-x64</RuntimeIdentifier> to <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>

    For example:

    <?xml version="1.0" encoding="utf-8"?>
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
        <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <UseWPF>true</UseWPF>
        <Platforms>x64</Platforms>
        <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
      </PropertyGroup>
    </Project>
    

    In this case, it will install the microsoft.netcore.app.runtime.win-x64/8.0.0 package.

    For example:

    enter image description here