2
votes

I am using the Azure Devops pipeline. From 2020/6/25, an error has occurred.

task:dotnet test Error: The framework'Microsoft.NETCore.App', version '2.2.0' was not found.

What I care about: When it was successful, the following display.

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.300

Tasks when it starts to fail:

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.301

The dotnet test portion of the Yml file is as follows version was used before the error. Added minorVersion and patchVersion, but they did not work. I added the x86 version of arguments, but it didn't work either.

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 file:

<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>

Is it possible to specify the above SDK version with the dotnet test task? If you know another solution, please help.

2
Can you share your pipeline's YAML file?Austin S
Austin S、返信ありがとう。 Ymlファイルのdotnet test部分を記載しました。 よろしくお願いいたします。fukufuku
Can you also include your test project .csproj file(s)?Austin S
The test project csproj file has been posted. Thank you for your support.fukufuku
2.2 is end of life. Switch to 2.1 or 3.1. And then install the required runtime if not yet installed, docs.microsoft.com/en-us/dotnet/core/tools/…Lex Li

2 Answers

0
votes

Error: The framework'Microsoft.NETCore.App', version '2.2.0' was not found.

Your test project TargetFramework is 2.2.0, yet specified in your testing task as 3.1.300

<TargetFramework>netcoreapp2.2</TargetFramework>
 task: DotNetCoreCLI@2
   displayName: dotnet test
   inputs:
     command: test
     # test core version
     # version: '2.2'
     majorVersion: '3'   <---
     minorVersion: '1'   <---
     patchVersion: '300' <--- 

You will want to make sure your project's .Net Core version is the same in:

  • Your project's .csproj file(s)

  • Any tasks specifying a runtime or version

  • Your App Service (managed in your Azure Portal)

0
votes

.NET Core 2.2 is end of life. https://dotnet.microsoft.com/download/dotnet-core/2.2/runtime/?utm_source=getdotnetcore&utm_medium=referral

I faced the same problem as well, found a workaround for it, before the test task add the below task,

steps:

  • task: UseDotNet@2

    displayName: 'Use .NET Core sdk 2.2.100'

inputs: version: 2.2.100

It basically adds 2.2 version on the fly. You can either use sdk / runtime. Make sure the version is same as in your project.