首页 > 解决方案 > .Net 5 Azure Pipeline - 找不到指定的 SDK 'Microsoft.NET.Sdk.BlazorWebAssembly'

问题描述

我将我们的项目升级到 .NET 5 并在构建时收到此错误 azure pipeline 错误:

The nuget command failed with exit code(1) and error(C:\agent\_work\91\s\src\Main.Blazor\Main.Blazor.csproj : error : C:\Program Files\dotnet\sdk\3.1.401\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\Sdk not found. Check that a recent enough .NET Core SDK is installed and/or increase the version specified in global.json.

Microsoft.NET.Sdk.BlazorWebAssembly找不到指定的 SDK

这是它失败的任务,并且.NET 5 已经安装在这台机器上,我可能缺少什么吗?

- task: NuGetCommand@2
   displayName: 'NuGet Restore'
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    vstsFeed: '842a57e5-e138-4563-9d88-36c4b1476f72'

标签: azureazure-pipelineswebdeployblazor-webassembly.net-5

解决方案


正如您在错误消息中看到的,似乎正在使用 .NET Core 3.1.401 sdk。

在实际运行任何 dotnet/nuget 命令之前尝试添加以下步骤:

- task: UseDotNet@2
      displayName: 'Use .NET 5.0.x'
      inputs:
        packageType: sdk
        version: '5.0.x'

推荐阅读