简体   繁体   English

如何创建触发NuGet更新包–重新安装的Powershell脚本?

[英]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. 我有一个nuget规范,可以在一个特定的文件夹上安装库文件(dll)和两个zip软件包。 Updating the packages is no issue when doing it from Visual Studio 2013 manually. 从Visual Studio 2013手动执行时,更新程序包没有问题。 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. 但是,当它从我们的CI服务器TeamCity和CCNet触发时,它仅更新dll文件,而不更新两个至关重要的zip软件包。

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. 我假设由于文件夹中存在以前的zip文件,因此可能难以覆盖文件,因为在VS2013中,提示会确认用户是否要覆盖这些文件。

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. 当我使用VS2013的Package Manager控制台时,可以轻松触发Update-Package –重新安装[Package ID],它将正确执行此工作。 Now, I need to do the same thing and apply some automation from our CI server. 现在,我需要做同样的事情,并从CI服务器中应用一些自动化。

If I understand it correctly, I can trigger nuget commands from powershell? 如果我正确理解它,可以从Powershell触发nuget命令吗?

I would greatly appreciate your inputs, I'm not an expert in this. 非常感谢您的投入,我不是专家。

You should run the update command from nuget.exe . 您应该从nuget.exe运行update命令 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 . update命令的参数之一是FileConflictAction ,它指示当要求覆盖或忽略项目引用的现有文件时应采取的措施: overwriteIgnoreNone

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. 您可能必须将所有内容包装在可能涉及EnvDTE的powershell脚本中,以设置路径并模仿从Visual Studio中的PowerShell控制台获得的环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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