.net core .net测试.net核心2.2.0框架项目中的Azure Devops管道错误

.net core .net测试.net核心2.2.0框架项目中的Azure Devops管道错误,.net-core,azure-devops,.net Core,Azure Devops,我正在使用Azure Devops管道。 从2020年6月25日起,发生了一个错误 任务:dotnet测试 错误:找不到框架“Microsoft.NETCore.App”版本“2.2.0” 我关心的是: 成功后,将显示以下内容 Welcome to .NET Core 3.1! --------------------- SDK Version: 3.1.300 开始失败时的任务: Welcome to .NET Core 3.1! --------------------- SDK Vers

我正在使用Azure Devops管道。 从2020年6月25日起,发生了一个错误

任务:dotnet测试 错误:找不到框架“Microsoft.NETCore.App”版本“2.2.0”

我关心的是: 成功后,将显示以下内容

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.300
开始失败时的任务:

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.301
Yml文件的dotnet测试部分如下 错误发生前已使用版本。添加了minorVersion和patchVersion,但它们不起作用。 我添加了x86版本的参数,但也不起作用

pool:
vmImage: 'windows-latest'

variables:
solution: '**/TamaWeb.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
#  disable.coverage.autogenerate: 'true'

steps:
- task: NuGetToolInstaller@0
inputs:
 versionSpec: '>=5' 
 checkLatest: true
 
- 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: DotNetCoreCLI@2
   displayName: dotnet test
   inputs:
     command: test
     # test core version
     # version: '2.2'
     majorVersion: '3' 
     minorVersion: '1' 
     patchVersion: '300' 
     arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --runtime win-x86'
     projects: '**/*[Tt]est/*[Tt]est.csproj'
  #   projects: '**/*Test/TamaCoreTest.csproj'
     nobuild: true
csproj文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="coverlet.msbuild" Version="2.8.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
    <PackageReference Include="Moq" Version="4.14.1" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
    <PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
    <PackageReference Include="NLog" Version="4.7.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\XXX\AAA.csproj" />
    <ProjectReference Include="..\XXX\BBB.csproj" />
    <ProjectReference Include="..\XXX\CCC.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Update="appsettings.test.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <ProjectExtensions><VisualStudio><UserProperties appsettings_1test_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

</Project>


netcoreapp2.2
假的
全部的
运行时间;建设;本地人;内容文件;分析仪;可传递的
保存最新
是否可以在dotnet测试任务中指定上述SDK版本? 如果您知道其他解决方案,请帮助

错误:找不到框架“Microsoft.NETCore.App”版本“2.2.0”

您的测试项目TargetFramework是2.2.0,但在测试任务中指定为3.1.300

netcoreapp2.2
任务:DotNetCoreCLI@2
显示名称:dotnet测试
投入:
命令:test
#测试核心版本
#版本:“2.2”

主要版本:“3”.NETCore2.2是生命的终结。

我也遇到了同样的问题,找到了解决方法,在测试任务之前添加以下任务

步骤:

  • 任务:UseDotNet@2

    displayName:“使用.NET核心sdk 2.2.100”

投入: 版本:2.2.100

它基本上是动态添加2.2版本。您可以使用sdk/runtime。
确保版本与项目中的版本相同。

能否共享管道的YAML文件?Austin s、返信ありがとう。 Ymlファイルの网络测试部分を記載しました。 よろしくお願いいたします。您还可以包括您的测试项目.csproj文件吗?测试项目csproj文件已经发布。谢谢你的支持。2.2是生命的终结。切换到2.1或3.1。然后安装所需的运行时(如果尚未安装),Austin S,感谢您的回复。>您的测试项目似乎是在2.2.0中创建的,但在Azure中指定为3.1。是的,我很关心上面的问题。但到目前为止,它一直运作良好。如果正如你所指出的,你可以去“variables”或“NuGetToolInstaller”,我也认为,我想知道参数是否有什么问题。我还将Yml文件的顶部添加到了问题中。谢谢。Virendra M Patil我刚才试过,但情况是一样的。也许设定一项任务是一个不好的位置。可以在“开始”之前设置任务吗DotNetCoreCLI@2"? 谢谢,这就是为什么在转换成.net core 2.1或.net core 3.x之前,它只是一个围绕这个问题的工作,只要在测试任务之前添加它,它就应该工作得很好。
 task: DotNetCoreCLI@2
   displayName: dotnet test
   inputs:
     command: test
     # test core version
     # version: '2.2'
     majorVersion: '3'   <---
     minorVersion: '1'   <---
     patchVersion: '300' <---