I'm using ArtifactoryNuget@1 task to restore NugetPackages from JFrog Artifactory. My Azure DevOps pipeline started to suddenly fail a week ago (31.1.2020) due the artifactory task restoring using Microsoft.NetCore.App version 2.1.14 where the DotNetCoreCLI@2 tasks after it use the version 2.1.15.
The actual error I'm getting from the DotNetCoreCLI@2 task is: NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.14, but with current settings, version 2.1.15 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore.
I'm doing self-contained deployment for the .Net Core deployment project so the project file has been set up for that.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
...
Pipeline is configured like this:
- task: ArtifactoryNuGet@1
inputs:
command: 'restore'
artifactoryService: 'xxxx'
solutionPath: 'xxxx.sln'
targetResolveRepo: nuget
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: xxxx.csproj'
arguments: '--configuration Release --runtime win10-x64 --no-restore
Everything worked beautifully before but now I cannot get the solution to build properly in Azure DevOps (local build works). My best guess is that the DevOps pipeline machines were updated with the 2.1.15 runtime but the JFrog ArtifactoryNuget task cannot utilize for some reason and it ends up using 2.1.14.
I've tried to see from the task source code how the version is selected but I think that goes into Nuget internals. I've also tried setting it explicitly with <RuntimeFrameworkVersion>
but that caused the ArtifactoryNuGet@1 task to use even older version 2.1.1. The nuget repo itself is a virtual repo combining nuget.local and nuget.remote.
The questions:
Thanks!
NOTE: The marked answer is a non-optimal workaround for the issue until something actually fixes it.
Generally it will request the latest patch installed when set TargetLatestRuntimePatch
to true
in the project file.
So, please make sure the version Microsoft.NetCore.App version 2.1.15
is existing in the Artifactory. According to your description seems the latest patch is version 2.1.14
in your JFrog Artifactory service.
If you scenario, please try this :
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<RuntimeFrameworkVersion>2.1.14</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Update="Microsoft.NETCore.App" Version="2.1.14" />
</ItemGroup>
If that doesn't work, please reference below links for further troubleshoot: