How to create a powershell script that triggers a NuGet Update-Package –reinstall?

1k views Asked by At

I have a nuget spec that installs both library file (dll) and two zip packages on a specific folder. Updating the packages is no issue when doing it from Visual Studio 2013 manually. However, when it is being triggered from either our CI servers TeamCity and CCNet, it is only updating the dll file and not the two zip packages which is vital.

I assume that since there are previous zip files existing on the folders, it may be having difficulty overwriting the files, since, in VS2013, a prompt confirms if the user wants to overwrite those files.

When I use the Package Manager Console from VS2013, I can easily trigger Update-Package –reinstall [Package Id] and it'll do the job correctly. Now, I need to do the same thing and apply some automation from our CI server.

If I understand it correctly, I can trigger nuget commands from powershell?

I would greatly appreciate your inputs, I'm not an expert in this.

1

There are 1 answers

0
David Brabant On BEST ANSWER

You should run the update command from nuget.exe. One of the parameters of the update command is FileConflictAction, which tells what action to take when asked to overwrite or ignore existing files referenced by the project: overwrite, Ignore, None.

You might have to wrap everything in a powershell script, possibly referring to EnvDTE, to set your paths and to mimick the environment you have from the PowerShell console within Visual Studio.