Install.ps1 doesn't run in VS2015 even if project is non-transitive #1245

Closed
OsirisTerje opened this Issue Aug 24, 2015 · 3 comments

Projects

None yet

4 participants

@OsirisTerje

Repro:

  1. Create a standard c# classlibrary
  2. Add the NUnit Test Adapter (https://www.nuget.org/packages/NUnitTestAdapter/)
  3. Look at the properties for the references nunit.core, nunit.core.interfaces and nunit.util. All of these should have CopyLocal= false
    This is done in the install.ps1 script in the package. It runs fine in VS2013 with Nuget 2.8, but not in VS2015 with Nuget 3.1.60724.766
@yishaigalatzer

NuGet 3.1.60724.766 definitely runs install.ps1 scripts when using packages.config

Can you please verify the content and debug the install.ps1 script(s?) in the packages.

Things that might be the culprits:

  1. Order dependency of scripts across packages.
  2. Dependency on reflection or internal APIs either in Visual Studio or NuGet?
  3. Depending on deprecated DTE or dlls from visual studio?

If you can confirm the scripts actually don't run, we will gladly take a look. Its that they work with any other package.

@OsirisTerje

Thanks, good to hear install.ps1 is working.
It can be that we call something that is no longer present, (2 above).
This is the script:
param($installPath, $toolsPath, $package, $project)
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
if ($reference.Name -ne "nunit.framework")
{
$reference.CopyLocal = $false;
}
}
}

Debugging it I see that the $package.AssemblyReferences is empty. Since this is something that comes from Nuget, I assume it should contain something ? In 2.8 it contains the actual referenced assemblies.

@yishaigalatzer yishaigalatzer added this to the 3.2 milestone Aug 24, 2015
@yishaigalatzer

Cool, that makes much more sense. I think $package is missing this information.

I suggest either fixing it by directly finding the specific reference in the project instead of using the assemblies in the package (so it works in all versions of NuGet). I understand this makes the script less generic, but it will make users work with any version of nuget on the box.

At the same time we will make sure this property is restored. Will start investigating this asap.

Thanks for working with us on this!

Aside:
I think an alternate solution that would work for project.json would be to use targets (this wont work for aspnet5 though).
I'm going to

@zhili1208 zhili1208 added a commit to NuGetArchive/NuGet.VisualStudioExtension that referenced this issue Aug 25, 2015
@zhili1208 zhili1208 fixed NuGet/Home#1245 a5937c8
@zhili1208 zhili1208 referenced this issue in NuGetArchive/NuGet.VisualStudioExtension Aug 25, 2015
Closed

fixed https://github.com/NuGet/Home/issues/1245 #69

@zhili1208 zhili1208 added a commit to NuGetArchive/NuGet.VisualStudioExtension that closed this issue Aug 27, 2015
@zhili1208 zhili1208 fixed NuGet/Home#1245 11b989f
@MeniZalzman MeniZalzman added 3 - Done and removed 2 - Working labels Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment