Search code examples
azure-pipelineswebdeployblazor-webassembly.net-5

.Net 5 - Azure Pipeline - The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found


I just upgraded a Blazor Web Assembly solution to .Net 5 and I'm getting the following error in an Azure Pipeline in the NuGet Command step:

error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found

The azure-pipelines.yml file is the following:

trigger:
- develop

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'SomeProjectNew.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: 'SomeProjectNew.sln'
    msbuildArgs: '/p:DeployOnBuild=true /p:PublishProfile=SomeProject-demo /p:Password=$(SomeProjectDemoWebDeployPassword)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Am I missing some step in the pipeline configuration to make this work with .Net 5 and the new blazor sdk?


Solution

  • Since you are using .Net 5, instead of using Nuget command, try to use Use .net core taskand Dotnet core task with restore command.

    - task: UseDotNet@2
      displayName: 'Use .NET Core sdk 5.0.100-rc.1.20452.10'
      inputs:
        packageType: 'sdk'
        version: '5.0.100'
        includePreviewVersions: true
    
    - task: DotNetCoreCLI@2
      displayName: 'dotnet restore'
      inputs:
        command: restore
        projects: '**/*.csproj'
    

    It's strongly recommended to use dotnet restore and dotnet build tasks for projects that target .net core. See this statement from Nuget task:

    Also take a look at this similar question here: Azure CI pipeline for Blazor .NET 5 doesn't work