Create NuGet package which installs references with Copy Local set to false
nuget
Solution
Yes you can do this with install.ps1, as you guessed.
Here's an example install.ps1 that will flip the flag on System.dll every time you run it. You should be able to get an idea how to do what you want using this example:
param($installPath, $toolsPath, $package, $project)
foreach ($reference in $project.Object.References)
{
if($reference.Name -eq "System")
{
if($reference.CopyLocal -eq $true)
{
$reference.CopyLocal = $false;
}
else
{
$reference.CopyLocal = $true;
}
}
}
But this MSDN documentation should help.
- The `Object` Hanselman uses resolves to the VSProject Interface.
- The `$project` variable NuGet gives you resolves to the Project Interface.
Problem
Is there a way to create a NuGet package where when the package is installed into a project it adds references to the dlls with "Copy Local" set to false? I assume it would be some kind of script within the 'install.ps1' file.