Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet restore not updating to new version when using * placeholder in package reference

Background

  • .NET Core CLI (e.g., dotnet restore, dotnet build)
  • SDK-style project files (e.g., <Project Sdk="Microsoft.NET.Sdk">)
  • An application project that depends on a package that I publish through a nuget server.
  • Semantic versioning of my packages (e.g., 1.6.10, is version 1.6.9, with backwards compatible fixes)
  • Project package references in the application with a patch placeholder (e.g., 1.6.*)
  • nuget.config file (with path to packages folder and list of NuGet sources.)

My project file for my application might contain this:

<PackageReference Include="MyDataAccessLibrary" Version="1.6.*" />

Here is the problem: When I publish a new version of my package to the nuget server, running dotnet restore on my development machine is not downloading that new version (if I have already been building against a previous version.)

For example, if I have been building against package version 1.6.9, I expected that dotnet restore would detect the recently published 1.6.10, install it, and use it when building my dependent application. That has not been my experience on my development machine. (On the build server, it works fine because it gets a clean copy for every build.)

Here is what I have been doing as a workaround on my dev machine:

  • Edit the project file, replacing 1.6.* with 1.6.10.
  • Run dotnet restore
  • Watch the new package version be downloaded
  • Edit the project file, reverting the 1.6.10 back to 1.6.*

Question: What is the right way to say, "please download the latest patch for a package" in the above situation?

like image 483
Wallace Kelly Avatar asked Sep 12 '18 15:09

Wallace Kelly


1 Answers

I think I found the answer... the --no-cache option on dotnet restore.

dotnet restore --no-cache
like image 59
Wallace Kelly Avatar answered Dec 09 '22 01:12

Wallace Kelly