Azure CI pipeline for Blazor .NET 5 doesn't work

生来就可爱ヽ(ⅴ<●) 提交于 2020-11-29 05:28:53

问题


I have an existing Azure CI pipeline for a WebAssembly Blazor application, that works with .NET Core 3.1.

I upgraded the application to use .NET 5 RC, and the pipeline doesn't work anymore.

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'

that work.

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.
...

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

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.


回答1:


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

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'



回答2:


I set up a simple app service on my azure account, and trying to deploy to it. I can do it with the 'Publish' functionality from inside Visual Studio, but I cannot do the same inside the pipeline. The Publish does everything, starting from building the solution. I know I have the zip files on the pipeline, but when I try for example

- task: AzureWebApp@1
  inputs:
    azureSubscription: '<details>'
    appType: 'webApp'
    appName: '<name>'
    package: '$(System.DefaultWorkingDirectory)/**/*.zip'
    deploymentMethod: 'auto'

I get this error:

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

I tried every other possibility, but I couldn't find a way...



来源:https://stackoverflow.com/questions/64232919/azure-ci-pipeline-for-blazor-net-5-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!