【问题标题】:Error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0错误 NETSDK1045:当前的 .NET SDK 不支持面向 .NET 6.0
【发布时间】:2021-12-12 05:39:31
【问题描述】:

我花了 2 个小时试图找出我的 Azure Functions .NET6(在 Windows 上)的管道出了什么问题。

Error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0.  Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.

【问题讨论】:

    标签: azure-devops .net-6.0


    【解决方案1】:

    我在这里找到了解决方案 https://jaliyaudagedara.blogspot.com/2021/07/azure-devops-building-projects.html
    如果我指定 .NET Core SDK 版本并将预览版本设置为 true,它会起作用

    - task: UseDotNet@2
      displayName: 'Use .NET Core sdk'
      inputs:
        packageType: 'sdk'
        version: '6.0.x'
        includePreviewVersions: true
    

    所以我的最终管道看起来像这样

    # .NET Core Function App to Windows on Azure
    # Build a .NET Core function app and deploy it to Azure as a Windows function App.
    # Add steps that analyze code, save build artifacts, deploy, and more:
    # https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core
    
    trigger:
    - master
    - main
    - dev
    
    variables:
      azureSubscription: 'XXXX'
      functionAppName: 'XXXX'
      vmImageName: 'windows-latest'
      workingDirectory: '$(System.DefaultWorkingDirectory)/XXXX'
    
    stages:
    - stage: Build
      displayName: Build stage
    
      jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)
    
        steps:
        - task: UseDotNet@2
          displayName: 'Use .NET 6 Core sdk'
          inputs:
            packageType: 'sdk'
            version: '6.0.x'
            includePreviewVersions: true
    
        - task: DotNetCoreCLI@2
          displayName: Build
          inputs:
            command: 'build'
            projects: |
              $(workingDirectory)/*.csproj
            arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release
    
        - task: ArchiveFiles@2
          displayName: 'Archive files'
          inputs:
            rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
            includeRootFolder: false
            archiveType: zip
            archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
            replaceExistingArchive: true
    
        - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
          artifact: drop
    
    - stage: Deploy
      displayName: Deploy stage
      dependsOn: Build
      condition: succeeded()
    
      jobs:
      - deployment: Deploy
        displayName: Deploy
        environment: 'development'
        pool:
          vmImage: $(vmImageName)
    
        strategy:
          runOnce:
            deploy:
    
              steps:
              - task: AzureFunctionApp@1
                displayName: 'Azure functions app deploy'
                inputs:
                  azureSubscription: '$(azureSubscription)'
                  appType: functionApp
                  appName: $(functionAppName)
                  package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
    

    【讨论】:

    猜你喜欢
    • 2020-01-24
    • 2019-03-11
    • 2022-08-21
    • 2018-06-09
    • 1970-01-01
    • 2019-02-10
    • 2019-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多