简体   繁体   中英

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

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.

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.

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