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?
Since you are using .Net 5, instead of using Nuget command, try to use Use .net core task
and 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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With