Including files in content without the containing folders

Topics: General
Mar 25, 2013 at 1:01 PM
Hi All,

I'm building a NuGet package from a *.csproj file.
I want to include a file from a different folder.

When I include content file with the exact path, the file is added directly under content folder.
When I use asterisk (**) in the folder path, the entire path is copied into the content folder.

For example, the project is saved in "root\Freebies.CSharp.csproj" and has the project structure


The command I'm running is
C:\root>.\.nuget\NuGet.exe pack Freebies.CSharp.csproj
I use this "Freebies.CSharp.nuspec":
<?xml version="1.0"?>
<package >
    <file src="..\Build\lib\Freebies.JavaApp.jar" target="content\lib" />
This all works well, and I get the content folder:

When I change the NuSpec file to reference the file:
    <file src="..\**\lib\Freebies.JavaApp.jar" target="content\lib" />
The package contains the entire path:

I am using TeamCity, and the path has to be relative to allow the package to build both on my computer and on TeamCity.

Any Idea how to get the file directly into the content folder when using relative path with **?

I'd really approcoate the help.

Mar 25, 2013 at 6:44 PM
If you have only one file, why do you want to change to ** ?
Mar 27, 2013 at 8:34 AM
Edited Mar 27, 2013 at 8:41 AM
Hi dotnetjunky,

Thanks! your question drove me to research this a bit more.

Actually, there are two Jar files that I want to include.
(and the plot thickens, the Jars have version numbers: Freebies.JavaApp-1.2.0.jar)

The build on TeamCity works well If I include:
    <file src="Build\lib\*.jar" target="content\lib" />
When running from TeamCity, the current directly is "root" and so "Build\lib*.jar" is valid.

On my computer, the NuGet package does not build with these settings.

When running from my own computer, I'm running from "root" directory as well.
I get this output:
C:\root>.nuget\NuGet.exe pack Freebies.CSharp\Freebies.CSharp.csproj
Attempting to build package from 'Freebies.CSharp.csproj'.
Packing files from 'C:\root\Build\bin\Debug'.
Using 'Freebies.CSharp.nuspec' for metadata.
Could not find a part of the path 
Looks like NuGet is now looking for the files in:
instead of:

Does NuGet set the current directory to the NuSpec file path?

Mar 27, 2013 at 6:31 PM
Yes, from inside the .nuspec file, all relative paths are evaluated against the nuspec file path.