0

I'm trying to use the simplest and most automated approach possible to create a few NuGet packages from some of our projects, by using the nuget pack [path-to-csproj] method.

For most of the projects I've tried this, the command line tool seems to understand the .Net framework version of the projects and it adds the output dll and xml files to the correct lib folder. In some other project, it is including a .css file to the content folder in the package, I assume because the file has a Content build action.

What exactly does this NuGet command include in the final package and how does it extract this information? Is there a comprehensive documentation on the file extraction from the csproj? I'd like to understand this process so that I can hopefully add my own files to it, like the app.config file and some code contracts assembly files without having to hardcode paths in the nuspec definition.

Community
  • 1
  • 1
julealgon
  • 7,072
  • 3
  • 32
  • 77
  • Using NuGet often seems to be an exercise in reverse-engineering the magic of how it works. Try adding or excluding a file in your project and see if it gets included. – NextInLine Feb 03 '15 at 23:42
  • @NextInLine Yeah I have to say, NuGet is probably the project I've been looking at the source code the most. I feel some of the stuff is very poorly documented. At least the code itself is quite good and clean. I don't feel I'd learn a lot by adding and removing files though... I need to actually know how it does things so that I can customize it if possible. – julealgon Feb 04 '15 at 12:09
  • A lot of the customization I've done (with co-workers) involves nuget + MSBuild tasks + powershell. NuGet is about 80% of what we need (with about 50% documented), and we don't really want to fork the [nuget.exe source code](https://nuget.codeplex.com/SourceControl/latest#src/CommandLine/) to get the remaining 20%. – NextInLine Feb 04 '15 at 15:44
  • @NextInLine At the moment what I'm doing is just calling `nuget pack` at build time, in the csproj, in case a certain property is set. At the moment, only TFS build is setting this property to true in the msbuild commandline. It really sucks though because one depends on hardcoded logic inside nuget command line to extract things from the csproj. Of course I could manually maintain the nuspec file and call pack against that, but I'd _really_ like to avoid that, because it introduces many redundancies and increases chances of things going wrong tremendously. – julealgon Feb 04 '15 at 17:16
  • @NextInLine I think maybe I'll try to _generate_ the nuspec file myself if it comes to that. Perhaps then I'll have complete control of how the package is generated. It pains me that it is a xml document though, it would be a lot easier if I could just pass the things it needs as arguments to the command line directly. I'm still not sure how I'll automate this stuff when I start packing all .net versions of the libraries... at the moment I'm just doing packing for the .Net45 version of the assemblies (a single csproj), but this will need to be expanded to Silverlight and .net35 later. – julealgon Feb 04 '15 at 17:20
  • You can try looking at the [nuget project issues](https://nuget.codeplex.com/workitem/list/basic) and see if there is are issues there you can up-vote that affect your use case. – NextInLine Feb 04 '15 at 23:00

0 Answers0