Reputation: 539
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)'
Upvotes: 7
Views: 2616
Reputation: 8832
.Net Core 3.0 is finally released. You just have to install .Net Core 3.0.100 as a first step:
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0.100'
inputs:
version: '3.0.100'
Full .yml
file with test and artifacts publish. Update this 'FolderName/ProjectName.csproj'
before running this.
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0.100'
inputs:
version: '3.0.100'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*Test/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
inputs:
command: publish
publishWebProjects: false
projects: 'FolderName/ProjectName.csproj'
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: 'publish artifacts'
Upvotes: 0
Reputation: 466
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
.
Upvotes: 2
Reputation: 333
As suggested in the comments you need to install .net core preview 9 before you can use it.
You need to put the code below before your use statement:
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0 (preview)'
inputs:
version: '3.0.100-preview9-014004'
Hope this helps. I use this yml to build on azure devops. I 'forgot' the global.json - added it and it worked.
Update: More from my working pipeline script
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Install .net core 3.0 (preview)'
inputs:
version: '3.0.100-preview9-014004'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
azure-pipelines.yml and global.json are in the root of my project folder.
Upvotes: 0