How to do I prevent NuGet asking about overwriting a file when restoring packages?

依然范特西╮ 提交于 2019-12-12 01:37:52

问题


We recently added Fody to some of our projects and locally this goes fine, but on the TeamCity build server, this causes problems, which I can replicate locally by running the following command in the Package Manager Console of VS2015:

PM> Update-package -reinstall
<snip ... />
Successfully uninstalled 'Fody 1.29.4' from Example.Project
Package 'Fody.1.29.4' already exists in folder 'D:\Projects\Examples\MySolutions\packages'
File Conflict
File 'FodyWeavers.xml' already exists in project 'Example.Project'. Do you want to overwrite it?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "N"):

On the build server, this message is repeated over and over until the logfile eats away all the free space on the data drive of the server (the last TC log became 28GB!)

I tried -NonInteractive, but this seems to have no effect on the build server, and locally, in the Package Manager Console it says it does not recognize that parameter:

PM> Update-package -reinstall -noninteractive
Update-Package : A parameter cannot be found that matches parameter name 'noninteractive'.
At line:1 char:42
+ Update-package -reinstall -noninteractive <<<< 
    + CategoryInfo          : InvalidArgument: (:) [Update-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand     

回答1:


It appears that there actually is an option to prevent this behavior:

-FileConflictAction Ignore

This will take the default action (no overwrite).

In TeamCity you can set this option in your NuGet configuration (select Advanced Options), at the bottom, in Command line parameters:



来源:https://stackoverflow.com/questions/34444062/how-to-do-i-prevent-nuget-asking-about-overwriting-a-file-when-restoring-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!