Home: Can we do Maven style snapshots?

Created on 6 Jul 2018  路  8Comments  路  Source: NuGet/Home

Now that project.json is dead how can you emulate maven style snapshots?

I want to mark a package as a snapshot version so nuget/Visual Studio always downloads the most current version of that package.

WaitingForCustomer

Most helpful comment

@red8888
No you don't need to change the csproj.
You only need to change it when you start depending on an entirely different version.
You would just have 1.0.0-rc.* and then whenever you run some specific restores it will download the latest version .
Those specific restores are listed here.
Please note that with the future addition of repeatable builds those gestures may change.

All 8 comments

NuGet already supports pre-release packages, which is kind of what snapshots are trying to achieve.

NuGet also has the concept of floating versions that allows you get the latest prerelease version of that said package.

What exactly are you trying to achieve here?
Please also refer to https://semver.org/#spec-item-9. Relying on a mix of stable/prerelease packages is generally not the best idea.

I want to mark a package as a snapshot version so nuget/Visual Studio always downloads the most current version of that package.

Like maven does it- this isn't a wierd use case.

Can the prerelease thing do that? I want to not have to modify the version number and have nuget always redownload the latest version- like maven snapshots

Even with maven, you still can't re-download the same version.
You need to purge the local repository of that version.

You can achieve a similar thing. The thing is that each package you release should have a unique identifier.
Then you can just float the prerelease version.
Example 1.0.0-rc.* would always get the latest RC (there's 30 min http caching as a perf optimization, but that can be bypassed).
Look at for example https://dotnet.myget.org/feed/nuget-build/package/nuget/NuGet.Frameworks, how we publish a package with each build.

Please refer to https://docs.microsoft.com/en-us/nuget/consume-packages/dependency-resolution and https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards for more info.

"--update-snapshots" correct me if im wrong but maven absolutely can and thats kind of the whole point!

Doing it your way means I still need to update the package reference right? Go into nuget package manager and install that version right? Maybe im missing something?

Maybe there is a VS extension or a build task that can selectively run "Update-Package 鈥搑einstall" on certain packages- by doing a string match for some identifying token in the version number or something?

@red8888
No you don't need to change the csproj.
You only need to change it when you start depending on an entirely different version.
You would just have 1.0.0-rc.* and then whenever you run some specific restores it will download the latest version .
Those specific restores are listed here.
Please note that with the future addition of repeatable builds those gestures may change.

Thanks for answering my questions. So to set that version like "1.0.0-rc.*" do I do that in packages.config or in PackageReference in csproj files? Our users are most familiar with nuget package manager though, is there a way to set a wildcard version from that GUI too?

Thanks again!

@red8888

Floating versions are only supported with PackageReferences in csproj.

packages.config is a rather old design at this point and we prefer if customers move towards PR whenever appropriate.

Floating versions docs

There's currently no UI handling for floating versions unfortunately.
https://github.com/NuGet/Home/issues/3788
https://github.com/NuGet/Home/issues/3101

Please note that updates/installs are way more performant and consistent in PackageReference that they don't need to be changed with the UI.

Closing as all the questions seem to be resolved, feel free to reopen or create a new issue if there are further related concerns.

Was this page helpful?
0 / 5 - 0 ratings