NuGet / Home

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

PackTask quietly doesn't include files with nuspec extension in nupkg #8637

Open dagood opened 5 years ago

dagood commented 5 years ago

Details about Problem

NuGet product used:

#> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
[...]
  3.0.100 [C:\Program Files\dotnet\sdk]

NuGet version: 5.3.0-rtm.6251+b75150f2f4127a77a166c9552845e86fb24a3282.b75150f2f4127a77a166c9552845e86fb24a3282

Worked before: Unknown.

Detailed repro steps

  1. Extract minimal repro project based on dotnet new classlib: PackNuspecContent.zip.

  2. dotnet pack

  3. Open obj\Debug\PackNuspecContent.1.0.0.nuspec, see the File items including a .nuspec:

    <file src="D:\temp\PackNuspecContent\targets\foo.nuspec" target="targets\foo.nuspec" />
    <file src="D:\temp\PackNuspecContent\targets\foo.nuspec.txt" target="targets\foo.nuspec.txt" />
    <file src="D:\temp\PackNuspecContent\targets\foo.txt" target="targets\foo.txt" />
  4. Open bin\Debug\PackNuspecContent.1.0.0.nupkg, open targets/, see that the .nuspec isn't included:

    ├───targets
    │       foo.nuspec.txt
    │       foo.txt

Other

My goal was to include a nuspec file in an MSBuild SDK tool package that the consuming project will use with nuget.exe pack. I don't think I'm blocked by this issue, but it's pretty surprising and took a bit to spot what was happening. 😄

nkolev92 commented 5 years ago

There was an old nuget.exe issue a while ago, https://github.com/NuGet/Home/issues/1290.

Back then we closed it's rather dangerous to change right now. I'm inclined to say the same thing here, but we'll discuss it internally before I close this.

dagood commented 5 years ago

Thanks! Did some searching but didn't think to look so far back, wow. I agree with this from that thread:

At the very least, issue a warning or something when ignoring user input.

Adding .txt to the file name and reversing it when the SDK runs was an easy workaround in my case (and allowing .nuspec doesn't really matter to me at this point), but the behavior was really confusing.

nkolev92 commented 5 years ago

Yeah, looking at those comments, I think a warning is a good idea. I'll add a logging tag to the issue.