简体   繁体   中英

Force re-download of solution and project NuGet packages without reinstall

Is there a way via NuGet.exe or within Visual Studio 2022, natively or via the Package Management Console, to only re-download all packages for a given solution and/or project without re-installing them?

This may sound odd, but we occasionally run into a scenario where our packages path mappings get wonky, and we correct the paths in the.csproj files and whatnot, but Visual Studio believes that the packages are installed due to their listing in the packages.config, yet in our mapped packages path, they are not downloaded.

We do not want to reinstall, as for many projects, that uninstalls and reinstalls the packages, causing unwanted changes to the code, as default templates and other things get changed.

We simply want to say "Hey Visual Studio, you see all these packages that you think are downloaded and installed in C:\NuGetPackages...? Yeah, they are not there. Please just download them. Don't reinstall them please."

Any way to do this in 2022 yet?

Only re-download all packages … without re-installing them.

If you only downloading the NuGet packages, they are just .nupkg files. If you download and install them, you will get some files like .dll files, .nupkg files, .xml files and so on. If you download and install them, then reference them in your project(such as installing them into your project by using VS or configuring in packages.config file), your project will connect to these NuGet packages.

The third situation obviously doesn't meet your requirements, so just focus on the first and the second situation. For only downloading the NuGet packages, I don't find many good methods. Maybe manually or writing some scripts to download them from nuget.org? But you want to use VS or NuGet.exe, so not possible I think.

For downloading and installing NuGet packages, or installing them to a specific folder for preparation. You may try and modify following command(nuget.exe, install command ):

nuget install <packageID> -version X.XX.X -OutputDirectory c:\XXXX

BTW, based on my check, there's no options in VS 2022 to only downloading the NuGet packages without installing them. And for above situations, perhaps some third-party tools will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM