问题描述
我有一个用于 WebAssembly Blazor 应用程序的现有 Azure CI 管道,可与 .NET Core 3.1 配合使用.
I have an existing Azure CI pipeline for a WebAssembly Blazor application, that works with .NET Core 3.1.
我将应用程序升级为使用 .NET 5 RC,但管道不再工作.
I upgraded the application to use .NET 5 RC, and the pipeline doesn't work anymore.
根据建议,我删除了 NuGet 任务,并插入了两个新任务:
Following suggestions, I removed the NuGet task, and I inserted two new tasks:
- 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]Test1ServerServer.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:a1sTest1ServerServer.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]Test1ServerServer.csproj(0,0): Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Project "D:a1sFluidTickets.sln" (1) is building "D:a1sTest1ServerServer.csproj" (2) on node 1 (default targets).
D:a1sTest1ServerServer.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Done Building Project "D:a1sTest1ServerServer.csproj" (default targets) -- FAILED.
...
在 StackOverflow 的另一个答案中,我阅读了有关添加新变量的信息:
In another answer here in StackOverflow, I read about adding a new variable:
MSBuildSDKsPath = C:agent\_work\_tooldotnetsdk5.0.100-rc.1.20452.10Sdks
但是如果我这样做,在构建任务之前,还原任务就会失败.所以看起来 SDK 在某种程度上是可访问的"...
还有其他想法吗?
提前致谢.
But if I do this, it's the restore task to fail, before the build one. So it looks like the SDK is 'reachable', in some way...
Any other idea?
Thanks in advance.
推荐答案
将 UseDotNet 任务更改为以下内容,以确保 Visual Studio 2019 预览版与 .NET5 预览版结合使用:
Change your UseDotNet task to the following in order to make sure that the Visual Studio 2019 preview is used in conjunction with .NET5 preview:
- 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 项目):
Full YAML pipeline for your reference (this is working for my Blazor WASM .Net 5 project):
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 .NET 5 的 Azure CI 管道不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!