简体   繁体   English

Azure Devops上的Net Core 3.0 SDK Preview 9的Visual Studio Build失败

[英]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: 我已经建立了一条管道,仅用于:

  1. Use the new SDK 使用新的SDK
  2. Implement a global.json file using the new SDK 使用新SDK实现global.json文件
  3. Use Nuget 5.x and Nuget restore to correctly obtain preview packages 使用Nuget 5.x和Nuget restore来正确获取预览包
  4. Visual Studio Build the solution Visual Studio构建解决方案

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.

相关问题 使用.Net Core SDK 3.0预览错误Visual Studio代码和Omnisharp扩展 - Error Visual Studio Code and Omnisharp Extension with .Net Core SDK 3.0 preview 将 Visual Studio 2017 与 .Net Core SDK 3.0 一起使用 - Use Visual Studio 2017 with .Net Core SDK 3.0 Azure DevOps - .NET Core Build包含Web.config文件 - Azure DevOps - .NET Core Build Include Web.config file Visual Studio 2017中的ASP.NET Core Angular模板无法使用“ SyntaxError:意外令牌”生成 - ASP.NET Core Angular template in Visual Studio 2017 fails to build with “SyntaxError: Unexpected token” C#8.0,.NET Core 3.0和Visual Studio之间的关系 - Relationship between C# 8.0, NET Core 3.0 and Visual Studio Visual Studio 2017 不支持定位 .NET Core 3.0 - Visual Studio 2017 not support targeting .NET Core 3.0 使用 ASP.Net Core SDK 3.0 preview8(Blazor 框架)上传图像 - Uploading image using ASP.Net Core SDK 3.0 preview8 (Blazor framework) Moq库和.NET Core预览3.0 - Moq library and .NET core preview 3.0 Visual Studio找不到.NET Core SDK? - Visual Studio can't find .NET Core SDK? Azure devops 在部署时在多个数据库上执行 ef core (.Net core 3.0) 迁移 sql 脚本(来自项目存储库) - Azure devops Executing ef core (.Net core 3.0) migration sql scripts (From project repository) at deploy time on multiple databases
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM