整个周末我都在为这个问题苦苦挣扎。
我无法成功构建 Net Core 3 SDK Preview 9(2019 年 9 月 4 日发布)。
我设置了一个管道,专门用于:
- 使用新的 SDK
- 使用新的 SDK 实现一个 global.json 文件
- 使用Nuget 5.x和Nuget restore正确获取预览包
- Visual Studio 构建解决方案
我在构建阶段 (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.
在第 2 步中实现 global.json
之前,我最初在 Nuget 恢复阶段 (3) 遇到了同样的错误,所以我知道 global.json
是被正确引用。
管道 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)'
最佳答案
以下对我有用。
设置以下变量:
variables:
MSBuildSDKsPath: 'C:\\hostedtoolcache\\windows\\dotnet\\sdk\\3.0.100-preview9-014004\\sdks'
设置全局json
- task: PowerShell@2
displayName: 'Global Json'
inputs:
targetType: 'inline'
script: 'dotnet new globaljson --sdk-version 3.0.100-preview9-014004'
另外,需要注意一件事,我在使用 Nuget 5
时遇到了问题。我使用了 Nuget 4.7.1
。
关于c# - Azure Devops 上的 Net Core 3.0 SDK Preview 9 的 Visual Studio 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57852267/