如何解决Blazor .NET 5的Azure CI管道不起作用
我有一个适用于.NET Core 3.1的WebAssembly Blazor应用程序的现有Azure CI管道。
我将应用程序升级为使用.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'
,
还值得注意的是,一旦您将 api 升级为使用 NET 5,您需要进入 Azure 门户 > 应用服务 > 您的 api > 配置 > 常规设置并将堆栈切换到 NET 并将 NET 框架版本切换到 NET 5。
,我在azure帐户上设置了一个简单的应用程序服务,然后尝试将其部署到该服务。我可以在Visual Studio中使用“发布”功能来完成此操作,但是我无法在管道中执行相同的操作。从构建解决方案开始,发布就可以完成所有工作。我知道我在管道上有zip文件,但是例如当我尝试
- task: AzureWebApp@1
inputs:
azureSubscription: '<details>'
appType: 'webApp'
appName: '<name>'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
deploymentMethod: 'auto'
我收到此错误:
Got service connection details for Azure App Service:'DevOpsBlazorticketsWebApp'
Trying to update App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"1"}
Deleting App Service Application settings. Data: ["WEBSITE_RUN_FROM_ZIP"]
App Service Application settings are already present.
Package deployment using ZIP Deploy initiated.
##[error]Failed to deploy web package to App Service.
##[error]To debug further please check Kudu stack trace URL : https://<details>
##[error]Error: Error: Failed to deploy web package to App Service. Internal Server Error (CODE: 500)
App Service Application URL: http://<details>
Finishing: AzureWebApp
我尝试了所有其他可能性,但是我找不到办法...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。