How reproduce VS2017 Package Manager command "Update-Package -reinstall" with Nuget CLI

Sergio

I've tried with Nuget Update, Nuget restore, but they are actually not the same and here's why:

I've created a Nuget pkg only to distribute an executable file. When I install the Nuget the executable is added to my project so I can reference it and run it within my application.

Now, I don't want that every developer has to install the Nuget to have the executable in their project, but I just want the .exe to be added when the project is built. And of course, the reference to the package in the config file is present.

If I run Update-Package -Id -reinstall(using the Package Manager of VS) a folder with the .exe is added to the project root, but if I do nuget update or nuget restore (using the nuget CLI) it only re-add the .exe into the packages folder.

The reason why I need to run the nuget CLI is because I'm using TeamCity and I want to add the .exe when the automatic build runs.

I hope it makes sense.

Leo Liu-MSFT

How reproduce VS2017 Package Manager command “Update-Package -reinstall” with Nuget CLI

I am afraid you can NOT do such things with NuGet CLI. That because NuGet CLI does not modify a project file or packages.config. When we modify the project file, we need to do it by NuGet API in Visual Studio, but only package manager console can provide access to visual studio objects:

https://github.com/NuGet/Home/issues/1512

That is the reason why I said the easiest way is using the command line Update-Package -Id -reinstall in your previous thread. Then I also gave you another way to resolve this issue from the root cause, using .targets file to copy the executable file to the the project root, please check my update answer.

Of course, there is another simple idea to resolve this issue, just add a pre-build event in your project to copy the executable file to the the project root:

xcopy  /Y "$(SolutionDir)packages\MyToolPackage.1.0.0\Tools\wkhtmltopdf.exe" "$(ProjectDir)"

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Nuget CLI in Visual Studio 2017 - How to run?

VS2015 nuget package manager not finding packages

Is there an alternative for vs Nuget Package Manager?

Run nuget package manager console from visual studio command prompt

VS2015 NuGet package manager not loading any online packages

How to create .NET Standard NuGet package with minimal dependencies in VS 2017?

Can't find the nuget package manager in visual studio 2017?

Including a dependent assembly into a NuGet package in VS2017

VS2017 set 'Build Action' to 'Content' in a nuget package

How to ship the stylecop.json and custom.ruleset files with a NuGet package in VS2017

Is there an equivalent to Update-package -reinstall when using nuget.exe?

Package Manager Console vs Nuget.exe build file behavior

How can I access the nuget package manager console on ubuntu 18.04.2

How to fix managed c++ assembly referencing specific NuGet package delivered dll version (VS2017)

How to run Nuget Package Manager Host in cmd / powershell

how to write command lines for install packages in package manager console of vs2017

How to run Visual Studio 2017 Package Manager commands through PowerShell or command line

How to open Nuget package manager console in Rider

i want to add Nuget Package Manager along with VS2017 installation. What will be the command?

Enable NuGet package manager in VS Installer through command line. (as part of automated script)

NuGet package manager settings

How to update Nuget Package Manager Without Visual Studio installed?

NuGet Package Manager Console Command Fails But Search -> Install Works

NuGet Package Manager windows not opening

Nuget Push in VS2017

Nuget Package Manager for Mac

Why are new packages been installed after using command Update-Package --reinstall

(405) Method Not Allowed with Visual Studio 2017 (NuGet) Package Manager

What is the difference between adding components to VS 2017 with "Extensions and Updates" versus "Nuget Package Manager"