Search code examples
msbuildbuild-processnant

Howto build C# solution for different frameworks?


Which choices I have to build a VS2008 solution for different target frameworks, with only "one click"? I need to build for .net-2.0 and netcf-2.0. The problem is that I need referencing different libraries for netcf-2.0.

I tried to do this with nant, but that seems to be a complicated task.


Solution

  • I don't use different build configurations.

    When I did this I created a separate project for the CF version. Inside the CF version the Compile property group uses links to all the original source files.

    The CF and full-framework libraries are covered by independent projects. Each project can have an independent set of post-build or pre-build tasks, an independent set of references, a distinct set of #defined symbols, etc.

    In my case, not all code used in the full-framework version of the library gets compiled for the CF version. Using partial classes, I factor the code used only for the full-framework version into separate modules, and I don't add links for those source files into the CF project.

    You could do the equivalent by using #if statements, and defining a CF symbol (or similar) in the .csproj file for the CF project.