How does a nuget package specify copylocal

1.1k views Asked by At

I have issues that I am dealing with where certain nuget installed package added via VS2012 have the copylocal value set to true where as others don't have any value set.

How does nuget know when to add copylocal and not to?

Is there some setting that I am missing in the nupkg file that I am missing?

I had a look at the source code for nuget (briefly) and it the copylocal value exists then it should be set to true.

e.g.

Install-Package System.Web.Mvc

resolves to

    <Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>

However

Install-Package Newtonsoft.Json

Resolves to

    <Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
1

There are 1 answers

0
rizan On

I kind of figured this out.

The answer lies partly here: http://msdn.microsoft.com/en-us/library/vslangproj.reference.copylocal

Although "Newtonsoft.Json" doesn't have the copylocal=true explicitly set in the csproj file, it seems the visual studio evaluates automatically when copylocal=true is set or not.

It seems nuget relies on the DTE integration to help it determine the value for copylocal.

I tested this out by running msbuild out of VS2012, removing System.Web.MVC from the GAC and it is copied to the bin dir.

I guess this only becomes an issue when one wants to open a compiled website the dll doesn't exist in the bin e.g. System.Web.MVC.

VS in this case does not know it should look in the GAC.