Search code examples
c++packagenugetnuspecinvalid-characters

Create NuGet Package with Special Character in Assembly Name


I have a project with C++ code that creates an assembly with a name like this: "C++Adapter.dll". I have not been able to create a proper NuGet package due to the "++" in the assembly name. When I run the nuget pack command-line, it goes and create a package but the assembly name is somehow changed and looks like this: "C%2B%%2B%Adapter.dll". Is there a workaround for this?

Here is what my .nuspec file looks like:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
  </metadata>
  <files>
    <file src="..\bin\*.dll" exclude="**\*.pdb;**\*.dll.metagen" target="MyFolder" />
  </files>
</package>

Solution

  • This thread pointed me to a workaround: nuget encodes the blank spaces in names of files

    In my case, I was using 7-Zip to unzip the NuGet package. That is when the filenames got messed up. I ran the command below and it worked (I tested with NuGet.exe v4.4.1).

    nuget.exe install MyPackage -OutputDirectory C:\test
    

    What this command does is it downloads and extracts the package into the output directory.