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

3

6

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/

Celom answered 12/12, 2023 at 8:53 Comment(0)
C
14

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

Catha answered 15/12, 2023 at 6:25 Comment(7)
It's working. Amazing what a single letter can do.Celom
I've been fighting with this for hours but this change worked. How did you figure that out?Hookworm
This fixed the problem for me, too (which was unrelated to MSIX). This seems like a bug in dotnet restore CLI.Declamation
A word of warning about this solution - before .NET 8, having the 'RuntimeIdentifier' property in the csproj file automatically enables publishing a self-contained application. Switching to 'RuntimeIdentifiers' breaks this behavior.Uniform
In my case, this change proceed to the next step but then I took this error: Manifest file at 'obj\Debug\net8.0-windows7.0\win-x64\staticwebassets.build.json' not found.Castellany
@VasilisPlavos have you found a fix?Claytor
@Claytor sure! check bellow :)Castellany
P
0

I have tested using the configuration shared by you, the pipeline runs successfully.

The image I am using is windows-latest. Please run NuGet restore before the build and check if it works.

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '***'

If you still have the same error after NuGet restore, please share your complete YAML file and the project configuration.

Pricefixing answered 12/12, 2023 at 12:12 Comment(8)
It didn't help. I have the YAML up to the build task. It is 300 lines long...Celom
I managed to get most of it under the 30000 character limit.Celom
I still can't reproduce the issue. If I don't run restore, the pipeline will fail with "Error NETSDK1004: Assets file 'D:\a\1\s\Test\obj\project.assets.json' not found". Would you please try to run restore in a VSBuild@1 task? Set msbuildArgs: > /p:RuntimeIdentifier=win-x64 /t:Restore Based on your description, it works on your local machine. If it's convenient, please set up a self-hosted agent on that machine and check what's the result.Pricefixing
I added a separate VSBuild task with the msbuildArgs /p:RuntimeIdentifier=win-x64 /t:Restore but the error still appeared when buildingCelom
I tried with a different MSIX project but the same pipeline, and still got the error.Celom
1. Would you please try to use DotNetCoreCLI@2 task to restore and build your project? 2. According to your description, you can build successfully on your local machine. You can set up a self-hosted agent on that machine. Then run your pipeline using the self-hosted agent. If it works, the issue may be related to the MS-hosted agent. 3. If it's convenient, please share a sample project that can reproduce the issue, so that I can test from my side.Pricefixing
Thanks, I can try that. I have made a minimal repro example here: github.com/tripleacoder/MSIXTestAppCelom
@Rye bread, I can reproduce the issue using your sample project. Tried the suggestion shared by Kevin Lu-MSFT, my pipeline can run successfully. Please try to use <RuntimeIdentifiers>win-x64</RuntimeIdentifiers> in your project and let us know if it works for you.Pricefixing
C
0

If you are using WPF, and the target framework is .NET8* and Azure DevOps, try to publish the application as a self-contained app.

To do it easily include also the property: <SelfContained>true</SelfContained>

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows7.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
</Project>
Castellany answered 10/7 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.