Search code examples
visual-studionugetnuget-spec

NuGet not throw the error when pack nupsec file with same file in the different foder


When I pack a .nuspec file to generate a package, which contains some files in the different folder, but a file exists on both folder, then I pack this .nuspec file. NuGet pack it successfully, but just include one and not throw the error.

My .nupsec file like:

  <files>
    <file src="foo\test.dll" target="Tools" />
    <file src="bar\test.dll" target="Tools" />
  </files>

I know I may overwrite the dll file in the tools folder, but NuGet should throw the error or warning about this overwriting.

Any suggestion?


Solution

  • NuGet not throw the error when pack nupsec file with same file in the different foder

    This is a known issue about the NuGet. The NuGet team is repairing it to support future releases.

    You can add your comment or vote for this issue on the GitHub: NuGet doesn't error when packaging nuspec with duplicate files. When there are enough communities vote and add comments for this feedback, the product team member will take this feedback seriously.

    At this moment, the workaround for this issue is using different name for the same file or target to the different folder, like:

      <files>
        <file src="foo\test.dll" target="Tools\foo" />
        <file src="bar\test.dll" target="Tools\bar" />
      </files>
    

    Hope this helps.