1

How do I create a nuget package that installs a config file only once?

Basically, I'm adding a log4net config file (+2 transform files for Debug + Release builds) via a nuget package to my project.

I want the file to be added on the first install and after that - it should never be updated, since it might have been customized by the developer.

This question: Is there a way to tell nuGet to install a file, into a project, only if the file is not already in the project? seems like a decent answer - but I can't see where the $filesToMove variable comes from....

Btw. I only need this to work in VS2015 for now - so I'm fine with using install scripts. (yeah, short-sighted - I know :-)

I do need to support the fact that this package can be used in multiple projects in the same solution. In this case it must install the file the first time it is installed in EACH project and not just for the first project...

Keil
  • 63
  • 4
  • You said you're ok with using an install script, did you attempt a solution with an install script? That's your answer right there. – imps May 08 '18 at 17:24
  • @imps The solution has an install script right now - to handle some other implementation details. The problem is that when you add the config file to the files collection in the nuspec - it is copied over regardless of what you do in the install file. Doing this in Visual Studio is ok - since it prompts you to ask whether it should overwrite the files or not. My problem is that I also need it to work in a build server - and there is no one to answer the prompt. – Keil May 09 '18 at 06:14
  • No files should be just copied regardless. What does nuspec look like? – imps May 09 '18 at 09:45

0 Answers0