Nuspec file element limitations

Jun 30, 2011 at 11:05 PM

I'm building a sample NuGet package for my library, and wish to include the source code for several sample C# projects in the content/ directory. However, doing something like this is non-ideal:

<file src="..\..\src\Samples\**" target="content\Samples\" />

Unfortunately, while this pulls in all the relevant source code, it also pulls in the obj/ directories.

For this reason, would it be possible to add either a) an 'exclude' wildcard attribute to the <file> element, b) allow regex expressions in the 'src' attribute, c) both?

Thanks very much.

Jun 30, 2011 at 11:31 PM
Why not copy the items you want over to another directory and include that one instead?
Jun 30, 2011 at 11:37 PM

No doubt, that's a possibility, but it then requires a pre-build script. It's all time- and space-consuming. Having directory exclusion built into NuGet.exe itself would be ideal, for sure.

Jun 30, 2011 at 11:38 PM

I noticed there is an -Exclude option for the `pack' command. Perhaps this could be extended to exclude directories? In any case, it would seem to make more sense to have this exclude option as a part of NuSpec; indeed even in the <file> element.

Jun 30, 2011 at 11:47 PM
Use the exclude like this:

nuget pack -exclude ..\..\src\Samples\obj\**

and it works.

the option to have it in the nuspec file is nice. I don't think this is the first time this has been requested though....
Developer
Jul 1, 2011 at 12:11 AM

You should be able to Exclude directories today by simply excluding all files under it. For instance if your folder structure is

SRC
└───Samples
    └─── Code.cs
    └───obj
        └─── Obj.dll
        └─── Obj.pdb

nuget.exe pack -Exclude Src\Samples\obj\*
or
nuget.exe pack -Exclude **\obj\*

should do the job.

Jul 1, 2011 at 1:38 AM

Thanks for the quick replies.

pranavkm: That almost worked! I changed it slightly to `-Exclude **\obj\**` and it did the job, so thanks.

ferventcoder: Yeah, I'm sure that would have done the job too; just happened to try pranavkm's first. Anyway, if this suggestion has been made a few times (and you seem to agree it would be useful), is there any chance of it appearing in the next release? :-) I would even take the time to submit the patch myself to get this working, but unfortunately I'm experiencing some weird build errors (namely a Target Invocation error and I'm also missing FxCop).

Cheers.

Jul 5, 2011 at 4:42 PM

So, any more thoughts on this guys? :-)

Jul 5, 2011 at 4:51 PM
File an issue. Be specific in the issue about what you want. It will be triaged.

If you want to get a quick response on it, get a lot of people to vote it up.

(sorry this was not clear from our conversation)
____
Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder