JoelHT-Landmark / NuGet-PackageNPublish

Project template and packaging targets file to allow easier Package'n'Publish integration with TFS (or other CI) builds.
Other
13 stars 12 forks source link

Packaging project includes all dlls in solution when build via TFS #7

Closed cliechty closed 11 years ago

cliechty commented 11 years ago

I have a solution with 4 projects: the package project, a class library that is packaged, and 2 mvc site projects. When I build the solution from visual studio the nuget package only includes the class library dll which is the desired outcome. However when I build the solution through tfs every dll from every project is included.

JoelHT-Landmark commented 11 years ago

This is actually an artefact of how TFS build differently to visual studio.

VS has a different output directory per project, whereas TFS build shares the output directory across all projects in a solution.

The way I work is to have any DLL that I'm creating as a separate solution - treat it as a product in its own right - and the MVC sites as one or more separate solutions - they publish process is different anyway.

This is actually the same bug that I raised myself as issue #3, and will be fixed at the same time - but I need a nice tab integrated in the project properties dialog to make configuring NuGet.PackageNPublish, and haven't yet had the chance to research this.

In the mean time, the plan is for the next build to only include dlls that are project references by default - which would solve your issue.

I'd like to know what you think.

Regards

Joel

cliechty commented 11 years ago

For this sort of process its too bad MS made tfs builds put all of the outputs into the same folder for the solution.

As a workaround I modified the _MSBuild.NugetPackageAndPublish.targets file in the project to copy only the dll I want included in the package.

Copying only the dlls from only the referenced projects would be my preferred method of selecting which dlls to include.

JoelHT-Landmark commented 11 years ago

The alternative is to replace the following lines in the package.tt file

  <file src="lib\**\*.dll" target="lib" />
  <file src="lib\**\*.pdb" target="lib" />

with more specific ones

  <file src="lib\**\MyCompany.MyProject.Common.dll" target="lib" />
  <file src="lib\**\MyCompany.MyProject.Common.pdb" target="lib" />

i.e. be absolutely specific about what DLLs you want packaged. Not quite as fire-and-forget as I'd like, but it's a good quick fix.

JoelHT-Landmark commented 11 years ago

Fixed by implementing the code in my comment above in release v0.7.0.0