[英]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). 我无法获得Net Core 3 SDK Preview 9(2019年9月4日发布)的成功构建。
I have set up a pipeline solely to: 我已经建立了一条管道,仅用于:
I'm getting the following errors with the build stage (4): 我在构建阶段(4)遇到以下错误:
Error : Unable to locate the .NET Core SDK.
错误:无法找到.NET Core SDK。 Check that it is installed and that the version specified in global.json (if any) matches the installed version.
检查它是否已安装,并且global.json中指定的版本(如果有)与安装的版本匹配。
Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
错误MSB4236:找不到指定的SDK“Microsoft.NET.Sdk.Web”。
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. 在第2步中实现
global.json
之前,我最初在Nuget还原阶段(3)遇到了同样的错误,所以我知道正确引用了global.json
。
Pipeline YAML: 管道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)'
As suggested in the comments you need to install .net core preview 9 before you can use it. 正如评论中所建议的那样,您需要先安装.net核心预览版9才能使用它。
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.
我使用这个yml来构建天蓝色的devops。 I 'forgot' the global.json - added it and it worked.
我'忘了'global.json - 添加它并且它有效。
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. azure-pipelines.yml和global.json位于我的项目文件夹的根目录中。
Set the following variable: 设置以下变量:
variables:
MSBuildSDKsPath: 'C:\\hostedtoolcache\\windows\\dotnet\\sdk\\3.0.100-preview9-014004\\sdks'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.