Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet: How can I change property of files with Install.ps1 file?

Tags:

I am creating NuGet package and for that I have created Nuspec manifest file. In content folder I have two files, test.exe and test.config. Now I would like to change property "Copy To Output Directory" of these the files to "Copy Always" in project, when any user installs this package.

I found related question NuGet how to apply properties to files, that shows can do this using PowerShell install.ps1 script, but I have no idea how to create that file.

like image 260
Arun Rana Avatar asked Dec 12 '11 12:12

Arun Rana


1 Answers

Your install.ps1 file should look something like this.

param($installPath, $toolsPath, $package, $project)  $file1 = $project.ProjectItems.Item("test.exe") $file2 = $project.ProjectItems.Item("test.config")  # set 'Copy To Output Directory' to 'Copy if newer' $copyToOutput1 = $file1.Properties.Item("CopyToOutputDirectory") $copyToOutput1.Value = 2  $copyToOutput2 = $file2.Properties.Item("CopyToOutputDirectory") $copyToOutput2.Value = 2 
like image 129
Brent Avatar answered Oct 10 '22 19:10

Brent