在代理上使用什么.Net Core版本 [英] What .Net Core version to use on agent

查看:38
本文介绍了在代理上使用什么.Net Core版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在dotnet核心测试管道上运行,在Windows Self托管代理上运行时,出现错误.

Working on a dotnet core test pipeline, running on a Windows Self hosted agent, I have errors.

当我的项目使用DotNet Core 3.1时,当我运行"dotnet --version"时,在提供5.0.100的代理上,我以为我必须安装DotNet Core 3.1,但在添加/删除程序"中,我看到的版本是3.1.301和5.0.100

As my project uses DotNet Core 3.1 and when I run "dotnet --version" on the agent it gives 5.0.100, I thought I had to install DotNet Core 3.1 but looking at Add/Remove Programs, I see versions 3.1.301 and 5.0.100

我的管道包含:

  • 工作:测试displayName:测试"脚步:
    • 任务:UseDotNet @ 2输入:packageType:"sdk"版本:"3.1.x"

    • job: Test displayName: 'Test' steps:
      • task: UseDotNet@2 inputs: packageType: 'sdk' version: '3.1.x'

      任务:NuGetAuthenticate @ 0displayName:'使用NuGet进行身份验证'

      task: NuGetAuthenticate@0 displayName: 'Authenticate with NuGet'

      任务:DotNetCoreCLI @ 2输入:命令:测试项目:"src/Tests/*.csproj"testRunTitle:测试"参数:-收集代码覆盖率""publishTestResults:是

      task: DotNetCoreCLI@2 inputs: command: test projects: 'src/Tests/*.csproj' testRunTitle: 'Tests' arguments: '--collect "Code coverage"' publishTestResults: true

      我添加了"UseDotNet";目的是设置我要使用的版本,但出现此错误:

      I added "UseDotNet" with the goal of setting the version I want to use but I got this error:

      ##[error]Failed to download or parse releases-index.json with error: {"code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"}
      

      我删除了"UseDotNet"然后我有:

      I removed "UseDotNet" and then I had:

      Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
      
      ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
      

      这是否意味着我应该将整个解决方案迁移到.Net 5?这似乎是一项艰巨的任务...

      Does it mean I should migrate the entire solution to .Net 5 ? That seems like a large task...

      感谢和问候.

      推荐答案

      如果代理包含.Net Core SDK/Runtime 5.x,除非您已锁定项目的SDK版本,否则可能会选择5.x SDK在Azure管道中.在Microsoft托管的代理上,.Net 5已设置为默认版本.

      If the agent contains .Net Core SDK/Runtime 5.x, unless you have locked down a SDK version for your projects, 5.x SDK might be picked up in the Azure pipelines. On Microsoft-hosted agents, .Net 5 has been set as the default version.

      您收到警告

      ## [警告] .NET 5与较旧的Nuget版本(< = 5.7)存在一些兼容性问题,因此,如果要使用较旧的Nuget版本(而不是dotnet cli)进行还原,则dotnet cli命令(例如dotnet build)依赖于此类已还原的软件包可能会失败.为减轻此类错误,您可以:(1)-使用dotnet cli还原,(2)-使用Nuget 5.8版还原,(3)-使用较旧的sdk版本(< = 3)使用global.json建立

      ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build

      NuGet 5.8是第一个支持.NET 5的版本.与其他工具版本一起使用时,它可能会导致生成可能中断的问题.您可能会在恢复项目时遇到问题&;解决方案,然后使用不匹配的工具版本进行构建.(请参阅本文)

      NuGet 5.8 is the first release to support .NET 5. When using it with other tooling versions, it may cause the issue that your builds can break. You may run into issues with restoring your projects & solutions and then building them using mismatched versions of tooling. (see this article)

      您可以检查代理计算机上是否已安装NuGet 5.8或更高版本.

      You can check if you have installed NuGet 5.8 or later on your agent machine.

      考虑到项目的.NET Core版本较旧,并且.NET Core 5已用作Azure Pipelines的默认版本,建议您将.NET Core 3.1项目更新为.NET Core 5.0.您可以参考文章" 从ASP.NET Core 3.1迁移到5.0 ".

      Consider the .NET Core version of your project is older, and .NET Core 5 has been used as the default on Azure Pipelines, I recommend you update your .NET Core 3.1 project to .NET Core 5.0. You can reference to the article "Migrate from ASP.NET Core 3.1 to 5.0".

      这篇关于在代理上使用什么.Net Core版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆