Abel
Abel

Reputation: 57159

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

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     

Upvotes: 2

Views: 1747

Answers (1)

Abel
Abel

Reputation: 57159

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:

teamcity commandline parameters

Upvotes: 2

Related Questions