Visual Studio生成无法在Azure Devops上运行Net Core 3.0 SDK Preview 9

Dav*_*d D 6 c# visual-studio .net-core azure-devops azure-pipelines

我整个周末都在为此苦苦挣扎。

我无法获得Net Core 3 SDK Preview 9的成功构建(2019年9月4日发布)。

我已经建立了专门用于:

  1. 使用新的SDK
  2. 使用新的SDK实施global.json文件
  3. 使用Nuget 5.x和Nuget Restore可以正确获取预览包
  4. Visual Studio构建解决方案

构建阶段(4)出现以下错误:

错误:无法找到.NET Core SDK。检查它是否已安装,以及global.json中指定的版本(如果有)是否与安装的版本匹配。

错误MSB4236:找不到指定的SDK'Microsoft.NET.Sdk.Web'。

在实施global.json步骤2 之前,我最初在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)'
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Dun*_*imu 2

以下内容对我有用。

设置以下变量:

variables:
  MSBuildSDKsPath: 'C:\\hostedtoolcache\\windows\\dotnet\\sdk\\3.0.100-preview9-014004\\sdks'
Run Code Online (Sandbox Code Playgroud)

设置全局json

  - task: PowerShell@2
    displayName: 'Global Json'
    inputs:
      targetType: 'inline'
      script: 'dotnet new globaljson --sdk-version 3.0.100-preview9-014004'
Run Code Online (Sandbox Code Playgroud)

另外,需要注意的一件事是,我在使用Nuget 5. 我用过Nuget 4.7.1