Tuesday, February 27, 2007

Targeting 1.1 with VS 2005

To do this we setup a project in VS 2005 and added only 1.1 references. We created our test assembly with 2.0 components such as rhino mocks. Everything built and all tests were passing.

Now setting up only 1.1 references is one thing, but enforcing 2.0 supported features, such as generics, to cause build errors, will only happen when you build with 1.1. This is not supported by default with 2005. However, a nice group of people have created a tool to do just that!

The tool is called MSBee and you can download it here

MSBee creates a new build target for the 1.1 framework. You need to add this target to your vs project file in an import node:
<Import Project="$(MSBuildBinPath)\MSBee\MSBuildExtras.FX1_1.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND '$(TargetFX1_1)'=='true'" />

You can easily edit your project files in visual studio from the right click menu -- unload the project, then edit the file.

Tada! You now have a 1.1 build target in VS 2005!

But you want to integrate this with your build server and your NANT script?

Here is a snipet to execute the msbuild target:

<exec program="${msbuildLocation}">
<arg value="${csprojFile}" />
<arg value="/t:Rebuild" />
<arg value="/p:OutputPath=${buildDir}\" />
<arg value="/p:Configuration=${build.solution.config}" />
<arg value="/p:TargetFX1_1=true" />


1 comment:

Jason W. Thompson said...

Thanks Wendy. This post helped me out today.