【问题标题】:How to fix Azure pipeline yaml asp.net sdk version that does not match如何修复不匹配的 Azure 管道 yaml asp.net sdk 版本
【发布时间】:2022-01-15 15:18:22
【问题描述】:

nuget 命令失败,退出代码 (1) 和错误 (C:\Program Files\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141, 5):错误NETSDK1045:当前.NET SDK不支持面向.NET 6.0。要么面向.NET 5.0或更低版本,要么使用支持.NET 6.0的.NET SDK版本。[D:\a\1\ s\app-code\app-code.csproj

我在上面遇到错误。 我正在使用只有 .net 6 的 Visual Studio 代码 2022 这是我的 yaml 文件代码:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'



- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

第一次使用 yaml,谁能告诉我如何调整 .net 版本以及在哪里添加什么代码。 很抱歉在写这个问题时出现任何错误。

【问题讨论】:

    标签: asp.net azure-devops yaml azure-pipelines-yaml azure-webapps


    【解决方案1】:

    错误 NETSDK1045:当前的 .NET SDK 不支持面向 .NET 6.0。以 .NET 5.0 或更低版本为目标,或者使用支持 .NET 6.0 的 .NET SDK 版本。

    这表明 .NET 6.0 尚未安装在 Azure Pipelines 中最新的托管构建代理上,在运行任何 dotnet 命令之前,需要将以下任务添加到管道中:

    需要在代理中安装.NET 6 SDK,在DotNetCoreCLI前添加:

    - task: UseDotNet@2
      displayName: 'Install .NET Core sdk 6.x'
      inputs:
        version: 6.x
    

    这将下载最新的 6.0 版本的 dotnet,并在构建时使用它。

    请参考SO线程

    【讨论】:

      猜你喜欢
      • 2020-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-19
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      相关资源
      最近更新 更多