I have a simple project used in a more complex solution;
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<BuildDependsOn>AfterClean</BuildDependsOn>
<FileVersion>4.2.0</FileVersion>
<Company>mycomp</Company>
<Product>test</Product>
<Copyright>Copyright � 2020</Copyright>
<OutputPath>....bin</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;NU1603;RT0099</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Polly" Version="[7.2.3]" />
</ItemGroup>
</Project>
I use msbuild to restore packages and build the solution:
msbuild test.sln "/property:Platform=Any CPU" "/property:Configuration=Release" /target:restore;build /p:RestorePackagesWithLockFile=true /p:RestoreLockedMode=true /p:RestoreForceEvaluate=true /verbosity:normal
and get the following packages.lock.json file generated:
{
"version": 1,
"dependencies": {
"net6.0": {
"Polly": {
"type": "Direct",
"requested": "[7.2.3, 7.2.3]",
"resolved": "7.2.3",
"contentHash": "DeCY0OFbNdNxsjntr1gTXHJ5pKUwYzp04Er2LLeN3g6pWhffsGuKVfMBLe1lw7x76HrPkLxKEFxBlpRxS2nDEQ=="
}
},
**"net6.0/win-x64": {}**
}
}
on next build with /p:RestoreForceEvaluate=false I get the following error:
test.csproj : error NU1004: The project’s runtime identifiers have changed from. Project’s runtime identifiers: , lock file’s runtime identifiers win-x64.The packages lock file is inco
nsistent with the project dependencies so restore can’t be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit –force-evaluate
option to run restore to update the lock file.
If I remove entry “,
** “net6.0/win-x64″: {}**” the second restore works without error;
Any hint on why this empty entry is added to “packages.lock.json” file?
adding an extra “dummy” reference to the project
e.g.
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="[4.3.0]" />
will fix the problem, because it will be added to the
“net6.0/win-x64” entry from “packages.lock.json” file.
Doru Popa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.