I have a msbuild script that builds multiple projects using TeamCity. It builds a few C++ builder 2010 projects, and some C# projects. It also creates an installer for them and packages it all. Now I have a new project that I want to add, but the problem is that it’s build using .Net Framework 4, while the other older ones, along with the build scripts themselves, target .Net Framework 2.
In the settings in TeamCity it’s selected to build using msbuild 2 and changing it to 4 (hoping it was backwards compatible) just causes massive amounts of errors.
I was wondering if there is a good way to make a specific projects build using msbuild 4 instead, without resorting to making new buildsteps in TeamCity.
I tried invoking msbuild 4 from msbuild 2 using the exec comand and it worked fine. But perhaps there is some “nicer” way of doing it.
Example of what “worked”
<Exec Command="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild /t:FooBar /p:Configuration=Debug ..\FooBar\FooBar.sln"/>
Update: I managed to get all the old stuff compiling using msbuild and .Net Framework 4. So this isn’t really an issue anymore.
I solved it the “correct” way. Making sure all the old stuff could be built using the newer msbuild and target the .Net Framework they were intended for. The approach of using exec also worked but always felt like a hack.