Azure DevOps 中的 .NET 8 给出“错误 NETSDK1112:未下载 Microsoft.NETCore.App.Runtime.win-x64 的运行时包”

Rye*_*ead 4 .net c# azure-pipelines msix

我已将 MSIX WPF 应用程序从 .NET 7 升级到 .NET 8,并且它在我自己的计算机上运行良好。但是当我尝试在 Azure DevOps 中构建它时,我收到错误:

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'.
Run Code Online (Sandbox Code Playgroud)

我在本地构建服务器上和使用托管代理时都会遇到相同的错误。

我使用这些任务在计算机上安装和验证 .NET 8:

- 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
Run Code Online (Sandbox Code Playgroud)

但这没有什么区别。

项目文件包含此内容(自 .NET 7 以来我没有更改过它)

 <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
 <RuntimeIdentifier>win-x64</RuntimeIdentifier>
Run Code Online (Sandbox Code Playgroud)

我使用此任务构建项目:

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: ''
Run Code Online (Sandbox Code Playgroud)

新:最小重现项目: https://github.com/tripleacoder/MSIXTestApp/

Kev*_*SFT 9

我可以重现同样的问题。

在此输入图像描述

要解决此问题,您可以<RuntimeIdentifier>win-x64</RuntimeIdentifier><RuntimeIdentifiers>win-x64</RuntimeIdentifiers>

例如:

<?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>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,它将安装该microsoft.netcore.app.runtime.win-x64/8.0.0软件包。

例如:

在此输入图像描述