Details about Problem
I've been struggling with the new "locked mode" of dotnet restore since release and I've finally been able to create repro steps.
The problems seems related to using different version of the .NET Core SDK on the same machine, in particular versions before the locked mode introduction alongside the new ones.
As the NuGet Package Cache is shared between all versions, if the package as been cached by an old version of dotnet.exe/nuget, it looks like the new .nupkg.metadata get created with an incorrect signature.
Example:
Newtonsoft.Json 12.0.1 has signature:
{
"version": 1,
"contentHash": "jmVyoEyk0In8r+AObYQyFKVFm7uSRzE0XSHSbEtBJcZDMV6DqJoyB4FLcHwprPVhAh826so0db3DIKXVnpGoPA=="
}
however if it was already in the Nuget Package Cache, when using the new dotnet.exe/nuget it get this signature
{
"version": 1,
"contentHash": "pBR3wCgYWZGiaZDYP+HHYnalVnPJlpP1q55qvVb+adrDHmFMDc1NAKio61xTwftK3Pw5h7TZJPJEEVMd6ty8rg=="
}
which obviously cause the locked mode feature to fail.
This behaviour seems consistent in different Windows versions and machines.
Not tested on Linux/MaxOs.
I believe it is a common scenario to use different versions of the SDK on a dev machine as well on a build agent (not everyone use disposable docker agents yet) e.g. via global.json in different projects
Happy to help investigate more but I will need someone to point me in the right direction.
Thank you
Product Versions
NuGet product used: dotnet.exe
Version pre locked mode used:
❯ dotnet --version
2.1.403
❯ dotnet nuget --version
NuGet Command Line
4.8.1.0
Version with locked mode used:
❯ dotnet --version
2.2.102
❯ dotnet nuget --version
NuGet Command Line
4.9.2.0
OS version: Win10 17763
Worked before? No
Detailed repro steps so we can see the same problem
- git clone https://github.com/alefranz/DotnetRestoreLockedMode
- Delete package from Nuget package cache in %userprofile%.nuget\packages\newtonsoft.json\12.0.1
cd DotnetRestoreLockedMode\NetSdk22
dotnet restore --force --force-evaluate
dotnet restore --force --locked-mode pass!
- Delete package from Nuget package cache in %userprofile%.nuget\packages\newtonsoft.json\12.0.1
cd ..\NetSdk21
dotnet restore --force
cd ..\NetSdk22
dotnet restore --force --locked-mode fail! :(
Sample Project
https://github.com/alefranz/DotnetRestoreLockedMode
Note the global.json is at the project level for simplicity, but it doesn't make any difference having different solutions.
Details about Problem
I've been struggling with the new "locked mode" of dotnet restore since release and I've finally been able to create repro steps.
The problems seems related to using different version of the .NET Core SDK on the same machine, in particular versions before the locked mode introduction alongside the new ones.
As the NuGet Package Cache is shared between all versions, if the package as been cached by an old version of dotnet.exe/nuget, it looks like the new
.nupkg.metadataget created with an incorrect signature.Example:
Newtonsoft.Json 12.0.1 has signature:
however if it was already in the Nuget Package Cache, when using the new dotnet.exe/nuget it get this signature
which obviously cause the locked mode feature to fail.
This behaviour seems consistent in different Windows versions and machines.
Not tested on Linux/MaxOs.
I believe it is a common scenario to use different versions of the SDK on a dev machine as well on a build agent (not everyone use disposable docker agents yet) e.g. via global.json in different projects
Happy to help investigate more but I will need someone to point me in the right direction.
Thank you
Product Versions
NuGet product used: dotnet.exe
Version pre locked mode used:
❯ dotnet --version
2.1.403
❯ dotnet nuget --version
NuGet Command Line
4.8.1.0
Version with locked mode used:
❯ dotnet --version
2.2.102
❯ dotnet nuget --version
NuGet Command Line
4.9.2.0
OS version: Win10 17763
Worked before? No
Detailed repro steps so we can see the same problem
cd DotnetRestoreLockedMode\NetSdk22dotnet restore --force --force-evaluatedotnet restore --force --locked-modepass!cd ..\NetSdk21dotnet restore --forcecd ..\NetSdk22dotnet restore --force --locked-modefail! :(Sample Project
https://github.com/alefranz/DotnetRestoreLockedMode
Note the global.json is at the project level for simplicity, but it doesn't make any difference having different solutions.