Grzegorz Dev
Grzegorz Dev

Reputation: 3143

NuGet - get latest lib version on build

I have 2 solutions:

From SolutionMyTool there are produced NuGet packages

On SolutionToolUsage side I have dependency

<PackageReference Include="MyTool" Version="1.1.*" />

Now on each build of SolutionToolUsage I want to get the latest version of MyTool.
Is it possible?

It seems that SolutionMyTool on 1st buiod gets "latest version" of MyTool (eg. 1.1.7).
Then each next build of SolutionMyTool is using this version (1.1.7), although in the meantime there were produced newer versions of MyTool.
How can I always get the "latest"?

Thank you ;]

Upvotes: 1

Views: 1727

Answers (2)

Grzegorz Dev
Grzegorz Dev

Reputation: 3143

As of 2020-January NuGet behaves like here.

If SolutionToolUsage has dependency

<PackageReference Include="MyTool" Version="1.1.*" />

Then on 1st build is taken newest version (eg. 1.1.2) of MyTool.
Then on each next build is taken this version (1.1.2) even if newer are available in NuGet Feed.

If you need "asked flow" the simplest workaround is to manually:

  • increase version of each MyTool with each lib build
  • setting explicitly this version in SolutionToolUsage

Although Microsoft sometimes "recommends" uninstalling and installing again MyTool. https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages

  1. Reinstalling a package during its development: Package authors often need to reinstall the same version of package they're developing to test the behavior. The Install-Package command does not provide an option to force a reinstall, so use Update-Package -reinstall instead.

Upvotes: 2

stefan
stefan

Reputation: 156

Just use an asterisk for the version.
The following line loads the latest version on every build.

<PackageReference Include="MyTool" Version="*" />

https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#floating-version-resolutions

EDIT
Maybe you have also to restore the project's dependencies with

dotnet restore

The command dotnet build implicitly restores packages.

Upvotes: 0

Related Questions