Failed to use .NET SDK agent in Azure DevOps Build Pipeline

后端 未结 4 1240
深忆病人
深忆病人 2021-02-19 06:33

I have a ASP.NET Core 2.1 and added a nuget package of Microsoft.WindowsAzure.Storage , But after pushing the code to repo, the build pipeline occurs package error while runnin

4条回答
  •  余生分开走
    2021-02-19 07:20

    As the error info indicates, it's not recommended to call latest 3.x sdk to restore,build,test,publish your project that targets asp .net core 2.1.

    Though in most of time the build can pass, but the Publish step(task) may encounter this issue:

    To resolve the issue:

    We should specify the .net core sdk version we want to use before running tasks like restore,build,test,publish...

    We could add a use .net core sdk task before other .net core tasks like this to pick up the .net core 2.1.x related version to do the following tasks instead of using .net core 3.x sdk:

    Classic UI:

    Specify 2.1.x+Include Preview Versions will pick up the latest version of 2.1 sdk.

    Yaml:

    In case you're using yaml format instead of classic UI format to configure the pipeline, its yaml format looks similar to this:

    steps:
    - task: UseDotNet@2
      displayName: 'Use .Net Core sdk 2.1.x'
      inputs:
        packageType: sdk
        version: 2.1.x
        installationPath: $(Agent.ToolsDirectory)/dotnet
        includePreviewVersions: true
    

    Hope it helps and feel free to correct me if I misunderstand anything:)

提交回复
热议问题