【发布时间】:2019-09-09 10:33:48
【问题描述】:
我整个周末都在为此苦苦挣扎。
我无法成功构建 Net Core 3 SDK Preview 9(2019 年 9 月 4 日发布)。
我已经建立了一个管道,专门用于:
- 使用新的 SDK
- 使用新的 SDK 实现 global.json 文件
- 使用 Nuget 5.x 和 Nuget restore 正确获取预览包
- Visual Studio 构建解决方案
我在构建阶段 (4) 遇到以下错误:
错误:无法找到 .NET Core SDK。检查它是否已安装 并且 global.json 中指定的版本(如果有)与 安装版本。
错误 MSB4236:指定的 SDK 'Microsoft.NET.Sdk.Web' 不能 找到了。
在步骤 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)'
【问题讨论】:
-
您需要在构建管道中的构建作业之前添加一个安装作业来安装预览。我在预览版 6 中遇到了类似的问题。
-
你能分享你的管道吗?
-
感谢 ilkerkaran。已经这样做了,但如果没有现在添加的完整管道,您将无法看到。
-
您使用的是什么代理和 Visual Studio? AFAIK,.NET Core 3.0 SDK 处于预发布状态,正式发布的 Visual Studio 不支持它,SDK 团队建议对使用预览版 SDK 的项目使用预览版 Visual Studio。因此,我们可能需要使用私有代理构建这个项目并预览 Visual Studios。
-
谢谢 Leo,是的,本地一切都很好,因为这就是我正在做的。显然这个问题出在 DevOps 上,我只是在管道中的 Visual Studio Build 配置下使用“最新”的 Visual Studio 版本。
标签: c# visual-studio .net-core azure-devops azure-pipelines