0

I am attempting to configure my project / nuget to auto update a specific nuget package. I am currently using NuGet Version 2.8.* and an using the Automatic Package Restore in Visual Studio strategy. My question is what is the best approach to get NuGet to auto update a project before my app builds? Is what I am trying to do even possible using the Automatic Package Restore strategy? Or do I need to use Command-Line Package Restore wrapped in MSBuild, and specify custom update command and target in the NuGet.targets file?

2 Answers 2

3

Not currently possible with Visual Studio tooling. NuGet will not automatically upgrade your package version. You must still do this manually.

Not recommended, but in theory, you could write your own script to query nuget.org for the latest version and then upgrade the version number in packages.config. But this seems like a dangerous approach.

Sign up to request clarification or add additional context in comments.

1 Comment

I agree. Updating a package should be a conscious decision. Package restore simply pulls down missing packages that have already been installed in your project.
1

This is an old post but in case someone lands here. One option could be using pre-build script to run below command:

nuget update configPath  packageid

Config path could be either project ".cproj" path, solution (.sln) path, or the package.config file path.

https://learn.microsoft.com/en-us/nuget/tools/cli-ref-update

Note that it seems nuget CLI does not work for .NET Core. For Core you need to use dotnet CLI which has integrated nuget command. But that does not have a separate update command (at the time of this post). You need to use add to update but that command needs an explicit version number. So a workaround could be calling remove and then add commands.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.