Blazor .NET 5的Azure CI管道不起作用 [英] Azure CI pipeline for Blazor .NET 5 doesn't work

查看:65
本文介绍了Blazor .NET 5的Azure CI管道不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个适用于.NET Core 3.1的WebAssembly Blazor应用程序的现有Azure CI管道.

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'

有效.

但是构建任务失败,并显示以下信息:

But the build task fails with:

...
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的另一个答案中,我读到有关添加新变量的信息:

In another answer here in StackOverflow, I read about adding a new variable:

MSBuildSDKsPath = C:\agent\_work\_tool\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks

但是,如果执行此操作,则在构建之前,还原任务将失败.这样看来,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管道不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆