Skip to content

Spurious "not added because the package already contains file" warnings #6001

@dougbu

Description

@dougbu

This is really two bugs: The files chosen automatically for inclusion when packing may contain duplicates. And, NuGet.exe emits warnings about the duplicates despite the user making no explicit choices.

Though these are "just warnings" it's very annoying, especially when a repo contains lots of packable projects. And, affected solutions have no workaround except completely changing the layout of their output folders.

/cc @rohit21agrawal @emgarten
/fyi @anurse

Details about Problem

  • NuGet.exe
  • NuGet version: 4.3.0.4406
  • OS version: Win10 Enterprise v1703 (15063.632)
  • Worked before?: Not sure when it worked. But, it must have because the directory layout involved has been really common in our (Microsoft's) solutions.

Detailed repro steps so we can see the same problem

  1. Clone the aspnet/WebHooks repo
  2. .\build.cmd

Expected

Clean build

Actual

About 130 warnings, all similar to

EXEC : warning : File 'WebHooks\bin\CodeAnalysis\Test\Microsoft.AspNet.WebHooks.Common.dll' is not
 added because the package already contains file 'lib\net45\Microsoft.AspNet.WebHooks.Common.dll' [WebHooks\src\Packages\Packages.proj]

Other suggested things

Likely root cause

Problem is caused by nesting of output directories and the wildcard search in PackCommandRunner’s GetFiles(…) method.

In this solution, most projects use an $(OutputPath) setting to $(WebHooksRootPath)bin\$(Configuration)\ in tools\WebHooks.settings.targets. Test projects individually (e.g. here) set $(OutputPath) to ..\..\bin\$(Configuration)\Test\. In other words, the test projects write assembly files et cetera into a subdirectory of the usual output folder.

WebHooks\bin\CodeAnalysis content

bin

WebHooks\bin\CodeAnalysis\Test content

test

Sample Project

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions