7

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.

Andrea
  • 555
  • 5
  • 28
  • The net5 SDK preview is only supported in the Visual Studio preview. In your UseDotNet task, you have to specify which version of VS to use – Akinzekeel Oct 07 '20 at 09:29
  • Oh, right, it makes sense... Could you please know how to do it? Thanks. – Andrea Oct 07 '20 at 21:51
  • I mean: you say UseDotNet, but I think you are referring to the VSBuild@1 task, where I can only specify 'Visual Studio 2019', and not also the exact version... – Andrea Oct 07 '20 at 21:58

2 Answers2

5

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'
Akinzekeel
  • 603
  • 4
  • 14
  • Thank you Akinzekeel, it's a good suggestion, although now I have another error: Error : Version 5.0.100-rc.1.20452.10 of the .NET Core SDK requires at least version 16.8.0 of MSBuild. The current available version of MSBuild is 16.7.0.37604. – Andrea Oct 08 '20 at 14:17
  • Which build agent / image are you using? Mine is working fine with ubuntu-latest – Akinzekeel Oct 08 '20 at 21:52
  • Things got worse. if I use ubuntu-latest, when it comes to the VSBuild@1 task I get the error :The current operating system is not capable of running this task. That typically means the task was written for Windows only – Andrea Oct 09 '20 at 12:26
  • Please see my updated answer. I don't use the VSBuild task btw, are you sure you really need that? – Akinzekeel Oct 09 '20 at 18:51
  • Really thank you again for your time. But I must have something different, in my setup, because with just your pipeline I get another very strange error: /opt/hostedtoolcache/dotnet/sdk/5.0.100-rc.1.20452.10/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.props(33,62): error MSB4184: The expression """.Configuration" cannot be evaluated. Method 'System.String.Configuration' not found. [/home/vsts/work/1/s/Test1/DbLibrary/DbLibrary.csproj] – Andrea Oct 10 '20 at 07:46
  • I tried to google it, but I cannot find anything... I'm getting crazy. I can use a 'manual' publish from inside Visual Studio to Azure, so I can anyway see that the application, and server controllers, works perfectly, but I would like to setup a proper pipeline, for it... – Andrea Oct 10 '20 at 07:46
  • Ah, and same exact error on all 5 projects of my solution. – Andrea Oct 10 '20 at 07:48
  • 1
    Ok, my fault! I had a problem with my local variables. Now it works, apparently! :-) Thank you again!!! :-) – Andrea Oct 10 '20 at 08:15
  • ...I tried in every way, all day: I couldn't find the way to deploy the build result to an App Service on Azure... :-( I'm using a YAML pipeline with two stages (Build and Release, of course), but whatever I try I always get different errors. Would you mind to share your release pipeline, for the sample we are talking about? Thanks again! – Andrea Oct 10 '20 at 16:29
  • Where are you trying to deploy this to? The build pipeline will output a zip file, so you may have to unzip this in your release pipeline – Akinzekeel Oct 11 '20 at 14:07
  • 1
    You can now use the official version like so: - task: UseDotNet@2 displayName: 'Use .NET 5 SDK' inputs: packageType: 'sdk' version: '5.0.100' – iBobb Nov 14 '20 at 00:34
1

It's also worth noting that once you upgrade your api to use NET 5 you need to go into Azure Portal > App Services > Your api > Configuration > General Settings & switch Stack to NET and switch NET framework version to NET 5.