.netnugetdotnet-restore

How to update to the latest floating version with lock file in dotnet?


I have project that references a nuget package. Here is a snippet from .csproj file:

<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
...

<PackageReference Include="MyPackage" Version="1.*" />

Now after the restore the lock file is created and a version is locked, e.g. 1.0.1. What I want to do now is to force to reevaluate floating version after I publish a new package. I did not manage to achieve that, whatever I call, the version stays the same. This is what I tried, but to no avail:

dotnet restore -f --force-evaluate --no-cache

I use Rider and tried to do that in the GUI by clicking restore there. It does work but not at once, I have to wait some time before a new version is detected until it's getting restored. I did not manage to figure out what command Rider issues to do the update or why it does not work at once.


Solution

  • Apparently deleting of the packages.lock.json works just fine, but it's hardly a very good solution, so I still hope for a better answer.