Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Build Fails for Net Core 3.0 SDK Preview 9 on Azure Devops

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:

  1. Use the new SDK
  2. Implement a global.json file using the new SDK
  3. Use Nuget 5.x and Nuget restore to correctly obtain preview packages
  4. Visual Studio Build the solution

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)'

enter image description here

like image 775
David D Avatar asked Sep 09 '19 10:09

David D


People also ask

How do I enable build Pipeline in Azure DevOps?

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.

Does Azure DevOps support .NET 6?

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.


1 Answers

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.

like image 137
Duncan Gichimu Avatar answered Oct 13 '22 02:10

Duncan Gichimu