I've been struggling with this one all weekend.
I cannot obtain a successful build for Net Core 3 SDK Preview 9 (released 4 September 2019).
I have set up a pipeline solely to:
I'm getting the following errors with the build stage (4):
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 MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
I was initially getting the same error during the Nuget restore stage (3) before implementing the global.json in step 2, so I know the global.json is being correctly referenced.
Pipeline YAML:
pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - visualstudio
steps:
- task: UseDotNet@2
  displayName: 'Use .Net Core sdk 3.0.100-preview9-014004'
  inputs:
    version: '3.0.100-preview9-014004'
    includePreviewVersions: true
- powershell: |
   $globaljson = '{"sdk": {"version": "3.0.100-preview9-014004"}}';
   $globaljson | out-file './test.app/global.json' -Encoding UTF8
  displayName: 'Global Json'
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.x'
  inputs:
    versionSpec: 5.x
    checkLatest: true
- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'
- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

Navigate to your team project on Azure DevOps. Navigate to Pipelines | Pipelines. Not to have two pipelines triggered later in the lab, disable the CI trigger for the template created pipeline (uncheck) and Save. Navigate back to Pipelines | Pipelines and click New pipeline to create a new build pipeline.
After running the entire test, I'm happy with the result. I was able to Code, Build and Deploy a . NET 6 API with C# 10, and I was able to deploy in Azure App Service using Azure DevOps pipeline without any hiccups.
The following worked for me.
Set the following variable:
variables:
  MSBuildSDKsPath: 'C:\\hostedtoolcache\\windows\\dotnet\\sdk\\3.0.100-preview9-014004\\sdks'
Set the global json
  - task: PowerShell@2
    displayName: 'Global Json'
    inputs:
      targetType: 'inline'
      script: 'dotnet new globaljson --sdk-version 3.0.100-preview9-014004'
Also, one thing to note, I ran into issues using Nuget 5. and I used Nuget 4.7.1. 
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