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

2

5

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?

Fleeta answered 12/11, 2020 at 16:36 Comment(0)
R
5

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

Rash answered 13/11, 2020 at 9:20 Comment(2)
Thanks Patrick. I'll try that now. Why Release Candidate though? Isn't the RTM version available for this?Fleeta
Setting version to '5.0.100' and removing includePreviewVersions worked. And then just a second step with dotnet publish. Thanks for your help :)Fleeta
F
1

Just in case somebody else is after the full yml file, here is what I ended up with:

trigger:
- develop

pool:
  vmImage: 'windows-latest'

steps:

- task: UseDotNet@2
  displayName: 'Install .NET 5 SDK'
  inputs:
    packageType: 'sdk'
    version: '5.x'
    
- task: DotNetCoreCLI@2
  displayName: 'Restore Nuget Packages'
  inputs:
    command: 'restore'
    projects: 'SomeSolution.sln'
    feedsToUse: 'config'
    nugetConfigPath: '.nuget/NuGet.config'

- task: DotNetCoreCLI@2
  displayName: 'Publish to Azure'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: 'SomeProjectFolder/SomeWebProject.csproj'
    arguments: '/p:PublishProfile=profile-name /p:Password=$(WebDeployPassword)'
    zipAfterPublish: false
    modifyOutputPath: false

My publish profile uses web deploy to deploy the app to an Azure App Service. This approach relies on a '.nuget/NuGet.config' file in source control, and a secret variable $(WebDeployPassword) defined on the pipeline (Secret Variables).

Fleeta answered 13/11, 2020 at 19:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.