I've read a handful of posts (see references below) and have yet to find a guide on best practices that is specific to my tech stack.
The goal: Create a single NuGet package targeting multiple .NET frameworks built from a single .csproj file via TeamCity using MSBuild and NuGet.
The constraints:
- Pull the code from the VCS only once.
- All compiled assemblies should be versioned the same.
- Single .csproj (not one per target framework).
I have two approaches in mind:
Create a single build configuration. It would contain three build steps: compile .NET 3.5, compile .NET 4.0, pack with NuGet. Each build step would be contingent upon success of the last. The only real problem I see with this approach (and hopefully there's a solution that I'm not aware of) is that each build step would require its own set of build parameters (e.g., system.TargetFrameworkVersion and system.OutputPath) to designate the unique location for the DLL to sit (e.g., bin\release\v3.5 and bin\release\v4.0) so that the NuGet pack step would be able to do its thing based upon the Files section in the .nuspec file.
Create multiple build configurations. One build configuration per the build steps outlined above. With this approach, it is easy to solve the TargetFrameworkVersion and OutputPath build parameters issue but I now have to create snapshot dependencies and share the assembly version number across the builds. It also eats up build configuration slots which is ok (but not optimal) for us since we do have an Enterprise license.
Option #1 seems like the obvious choice. Options #2 feels dirty.
So my two questions are:
- Is it possible to create parameters that are unique to a build step?
- Is there a third, better approach?
References:
- Multi-framework NuGet build with symbols for internal dependency management
- Nuget - packing a solution with multiple projects (targeting multiple frameworks)
- http://lostechies.com/joshuaflanagan/2011/06/23/tips-for-building-nuget-packages/
- http://msdn.microsoft.com/en-us/library/hh264223.aspx
- https://stackoverflow.com/a/1083362/607701
- http://confluence.jetbrains.com/display/TCD7/Configuring+Build+Parameters
- http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package