NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

nuget pack packs NUnit test adapter #8253

Closed pascalberger closed 4 years ago

pascalberger commented 5 years ago

If a project contains NUnit test adapter v2 and a nuget pack myproject.csproj is called, nuget does add the files to the content folder. Defining the dependency to NUnitTestAdapter as developmentDependency does not help since the package imports .props files.

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): nuget.exe

NuGet version (x.x.x.xxx): 5.0.2.5988

dotnet.exe --version (if appropriate): -

VS version (if appropriate): -

OS version (i.e. win10 v1607 (14393.321)): Microsoft Windows [Version 10.0.17763.379]

Worked before? If so, with which NuGet version: -

Detailed repro steps so we can see the same problem

  1. Create an assembly and add NUnitTestAdapter NuGet package.

  2. Run nuget pack myproject.csproj

...

Other suggested things

Verbose Logs

WARNING: NU5100: The assembly 'content\NUnit.VisualStudio.TestAdapter.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\Mono.Cecil.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\Mono.Cecil.Mdb.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\Mono.Cecil.Pdb.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\Mono.Cecil.Rocks.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\nunit.core.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\nunit.core.interfaces.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
WARNING: NU5100: The assembly 'content\nunit.util.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.

Sample Project

See https://github.com/pascalberger/nu5100-testadapter-repro

rrelyea commented 5 years ago

Notes from doing repro:

pascalberger commented 5 years ago

https://github.com/NuGet/Home/issues/6138 seems to be a similar issue (where something was packed because of imported .props files). In my case I also have a .nuspec file beside which contains a <files> section, but files from adapter will still be added.

While test projects normally don't be packed as NuGet packages, I think this might be a general issue with a certain kind of packages. The case with the adapter popped up when I tried to add the adapter to a shared project used by all test projects, which is also packaged as a NuGet package (this case can easily be worked around by adding the adapter to the test projects directly).

Cylox commented 4 years ago

I am having the same issue with nuget CLI 4.6.2. NUnit3.TestAdapter.dll and the nunit.engine.dll get added to the content folder of the built package regardless of having a nuspec file with or without a section. It seems like the NUnit3.TestAdapter .props file adds the assemblies to the content folder. But why? DevelopmentDependency also has no effect.

nkolev92 commented 4 years ago

Hey @pascalberger

After further investigation, the repro for this bug seems equivalent to https://github.com/nuget/home/issues/6138, so I am closing this bug as equivalent to that one.