0

I know this has been asked before but there isn't any answer or nuget isn't listening well to my packagereference.

I have a private nuget repo, with 2 assemblies:

<PackageReference Include="ProjectX.Core" Version="1.0.0.20" />
<PackageReference Include="ProjectX.Domain" Version="1.0.0.20" />

What I want is nuget to automatically get te latest version upon restore (via azure devops), according to the official docs I should do something like:

<PackageReference Include="ProjectX.Core" Version="1.*" />
<PackageReference Include="ProjectX.Domain" Version="1.*" />

But then when I'm looking it tries to revert to version 1.0.0 (which isn't even available).

How to make nuget to automatically get the latest version?

Elger Mensonides
  • 6,930
  • 6
  • 46
  • 69

1 Answers1

0

"works for me". If it doesn't for you, if you can provide a Minimal, Complete, and Verifiable example, we might be able to debug and see what's going wrong.

reproduction steps:

# setup isolated nuget environment
dotnet new nugetconfig
# you need to download nuget.exe for these commands, otherwise you have to hand edit nuget.config
nuget config -configfile .\nuget.config -set globalPackagesFolder=gpf
nuget sources -configfile .\nuget.config remove -name nuget
nuget sources -configfile .\nuget.config add -name local -source source

# create nupkgs
dotnet new classlib -n MyLib
cd MyLib
dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.1
dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.2
dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.10
cd ..

# use latest version
dotnet new console -n MyApp
cd MyApp
dotnet add package MyLib --version "1.*"

# check version used. I'm using Powershell
Select-String -Path .\obj\project.assets.json -Pattern MyLib/
zivkan
  • 12,793
  • 2
  • 34
  • 51