Let's say I have a Windows Forms application with a few NuGet packages that are important and need to be kept up-to date.
Is it somehow possible to update NuGet packages programmatically from a non-development environment? With a non-development environment I mean a random user that is running the WinForms application (having it installed on their PC).
I've read some things about using nuget.exe
, but updating the NuGet packages should result in .dll files to be placed in the installation folder.
You can do that, but you should not do it. NuGet packages are development dependencies and not meant to be updated arbitrarily in an already compiled application or at the customer site, because:
That being said, do not do it. Instead, follow a responsible software development cycle, where you update packages and test your application thoroughly before delivery and provide frequent updates of you whole application to your customers.
Nevertheless, for educational purposes, you can install packages locally with NuGet CLI tools, in this example nuget.exe
. You need to specify the package identifier, the output directory and the framework, like net472
for .NET Framework 4.7.2. This will extract the contents, as well as the package itself to the output folder in the package folder structure that will not match your target directory structure. From there, you would need to copy the assets that you need into your install directory e.g. with a copy script. Apart from not being the right thing to do, this is very cumbersome and most likely deemed to fail.
nuget install <PackageId> -OutputDirectory <OutputDirectory> -Framework <Framework>