Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pack improperly encodes filenames #5726

Closed
phillijw opened this issue Aug 8, 2017 · 6 comments
Closed

Pack improperly encodes filenames #5726

phillijw opened this issue Aug 8, 2017 · 6 comments

Comments

@phillijw
Copy link

phillijw commented Aug 8, 2017

Details about Problem

NuGet product used: Package Manager Console

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

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

VS version (if appropriate): VS Enterprise 2017 (15.2)

OS version (i.e. win10 v1607 (14393.321)): win 7

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

Detailed repro steps so we can see the same problem

  1. Create a nuspec file

  2. In the , include a file with spaces in the name (you may have to use a wildcard)

  3. Generate nupkg by running nuget pack

  4. Rename nupkg file to .zip and view. You will see %20 instead of spaces in filenames (same for commas and other special characters)

...

Other suggested things

Verbose Logs

PM> nuget pack Data/Data.csproj -verbosity detailed
.....
Added file 'Web.Australia, New Zealand (ANZ) - Dev.config'.
Added file 'Web.Australia, New Zealand (ANZ) - Production.config'.
Added file 'Web.Australia, New Zealand (ANZ) - Staging.config'.
Added file 'Web.Australia, New Zealand (ANZ) - Test.config'.
Added file 'Web.config'.
Added file 'Web.Debug.config'.
Added file 'Web.Europe, Middle East, Africa (EMEA) - Dev.config'.
Added file 'Web.Europe, Middle East, Africa (EMEA) - Production.config'.
Added file 'Web.Europe, Middle East, Africa (EMEA) - Staging.config'.
Added file 'Web.Europe, Middle East, Africa (EMEA) - Test.config'.
Added file 'Web.North America (NA) - Demo.config'.
Added file 'Web.North America (NA) - Dev.config'.
Added file 'Web.North America (NA) - Production.config'.
Added file 'Web.North America (NA) - Staging.config'.
Added file 'Web.North America (NA) - Test.config'.
Added file 'Web.Release.config'.

Successfully created package 'C:\repos\..\Data.1.0.0.0.nupkg'.
...
PM> 

As you can see, the filenames appear proper in the output but in the nupkg file itself they are transformed with special characters being URL encoded. When they get unpacked, they are not decoded.

@phillijw
Copy link
Author

phillijw commented Aug 8, 2017

Just saw this which is likely the fix: #2389

@nkolev92
Copy link
Member

nkolev92 commented Aug 9, 2017

@phillijw Can you please try using a newer version of the exe?
You can find them here: https://dist.nuget.org/index.html

@phillijw
Copy link
Author

phillijw commented Aug 9, 2017

Our build server was happy with it using a newer version, yes. So that did work. I expected VS2017 to have a newer version with it although I might misunderstand how they are connected.

@nkolev92
Copy link
Member

Thanks for checking that @phillijw, Glad it's fixed!
NuGet.exe ship-cycle is now aligned VS 2017 ship cycle, but it doesn't ship within VS.
Update 4.3 of the exe will be update 15.3 for VS etc.

@heidemn
Copy link

heidemn commented Aug 18, 2017

I tried nuget.exe v4.1.0 and v4.3.0, as well as older versions, and had a problem with filenames containing spaces:

The [Content_Types].xml contained lines like
<Override PartName="/ElectronDist_1.0.0.0/Contents/Frameworks/Electron Framework.framework/Electron Framework" ContentType="application/octet" />
This made the package fail to install in VS 2015, and fail to open in the latest version of NuGet Package Explorer, 3.23.0.0:
"Part URI is not valid per rules defined in the Open Packaging Conventions specification"

If I remove all occurrences of "Override" having a "PartName" containing spaces, the package installs successfully.
Please fix, since it is annoying to manually edit the .nupkg file.

Note that this seems to occur only for binary files without a well-known file extension.

@dander
Copy link

dander commented Sep 5, 2019

Just a note for others who may run across this... This change makes NuGet generate packages that are incompatible with https://www.nuget.org/packages/NuGet.Core/

It uses System.IO.Packaging to read the package, which cannot even see files that have not been uri encoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants