.Net 5 - Azure Pipeline - 找不到指定的 SDK 'Microsoft.NET.Sdk.BlazorWebAssembly'

Aug*_*eto 5 webdeploy azure-pipelines .net-5 blazor-webassembly

我刚刚将 Blazor Web Assembly 解决方案升级到 .Net 5,并且在 NuGet 命令步骤的 Azure Pipeline 中出现以下错误:

错误 MSB4236:找不到指定的 SDK 'Microsoft.NET.Sdk.BlazorWebAssembly'

azure-pipelines.yml 文件如下:

trigger:
- develop

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'SomeProjectNew.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: 'SomeProjectNew.sln'
    msbuildArgs: '/p:DeployOnBuild=true /p:PublishProfile=SomeProject-demo /p:Password=$(SomeProjectDemoWebDeployPassword)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
Run Code Online (Sandbox Code Playgroud)

我是否遗漏了管道配置中的某些步骤,以使它与 .Net 5 和新的 blazor sdk 一起使用?

Pat*_*SFT 5

由于您使用的是 .Net 5,而不是使用 Nuget 命令,请尝试使用Use .net core taskDotnet core task与还原命令。

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.100-rc.1.20452.10'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'
    includePreviewVersions: true

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'
Run Code Online (Sandbox Code Playgroud)

我们强烈建议您在使用dotnet restoredotnet build任务项目这一目标.net core。请参阅Nuget 任务中的此声明

也在这里看看这个类似的问题:Blazor .NET 5 的 Azure CI 管道不起作用

  • 将版本设置为“5.0.100”并删除 includePreviewVersions 有效。然后是 dotnetpublish 的第二步。感谢您的帮助 :) (3认同)