我有一个用于 WebAssembly Blazor 应用程序的现有 Azure CI 管道,可与 .NET Core 3.1 配合使用。
我升级了应用程序以使用 .NET 5 RC,但管道不再工作。
根据建议,我删除了 NuGet 任务,并插入了两个新任务:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 5.0.100-rc.1.20452.10'
inputs:
version: '5.0.100-rc.1.20452.10'
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
那个工作。但是构建任务失败了:
...
ValidateSolutionConfiguration:
Building solution configuration "release|any cpu".
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
##[error]Test1\Server\Server.csproj(0,0): Error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
D:\a\1\s\Test1\Server\Server.csproj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
##[error]Test1\Server\Server.csproj(0,0): Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Project "D:\a\1\s\FluidTickets.sln" (1) is building "D:\a\1\s\Test1\Server\Server.csproj" (2) on node 1 (default targets).
D:\a\1\s\Test1\Server\Server.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Done Building Project "D:\a\1\s\Test1\Server\Server.csproj" (default targets) -- FAILED.
...
在 StackOverflow 的另一个答案中,我阅读了有关添加新变量的信息:MSBuildSDKsPath = C:\agent\_work\_tool\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks
但是,如果我这样做,那么在构建任务之前,还原任务就会失败。所以看起来SDK在某种程度上是“可达的”......还有其他想法吗?
提前致谢。
最佳答案
将 UseDotNet 任务更改为以下内容,以确保 Visual Studio 2019 预览版与 .NET5 预览版结合使用:
- task: UseDotNet@2
displayName: 'Use .NET 5 SDK (preview)'
inputs:
packageType: 'sdk'
version: '5.0.100-rc.1.20452.10'
vsVersion: '16.8.0'
includePreviewVersions: true
完整的 YAML 管道供您引用(这适用于我的 Blazor WASM .Net 5 项目):pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
displayName: 'Use .NET 5 SDK (preview)'
inputs:
packageType: 'sdk'
version: '5.0.100-rc.1.20452.10'
vsVersion: '16.8.0'
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: 'NuGet restore'
inputs:
command: 'restore'
projects: 'MyProject/MyProject.csproj'
verbosityRestore: 'Normal'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
zipAfterPublish: true
command: publish
publishWebProjects: false
projects: 'MyProject/MyProject.csproj'
arguments: '-c $(Build.Configuration) -o $(Build.ArtifactStagingDirectory) --no-restore'
- task: PublishBuildArtifacts@1
displayName: 'Publish'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
关于blazor - Blazor .NET 5 的 Azure CI 管道不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64232919/