So new week, new post, and getting back to what I really started this blog. I like sharing knowledge, but part of the reason I blog about new versions of software is so that it motivates me to read up on what’s coming up, but the post today is typical of what I enjoy writing about the most. This post is about how to get projects that are unsupported by MSBuild built in an automated build.

Some projects cannot be compiled using MSBuild. Here is a list of project types that we can file under this category:

  • rptproj
  • dwproj
  • dtproj
  • vdproj
In this instance create a target that uses the Exec task in MSBuild to execute devenv.com via the command line. We use devenv.com as devenv.exe does not provide output, making debugging a chore, and can launch UI, which is far from ideal in a build. With devenv.com, we can also redirect the output if we wish to.

In a PropertyGroup, create key value pairs for the following:

  • Location on devenv on server (even if you do not have Visual Studio installed you can copy/paste into a directory… I think. You may need to add a few extra items.)
  • The location of the solution that has the unsupported project
  • The location of the unsupported project
  • The configuration you want to build (debug/release/custom…)
Now build your Exec task using the values you have provided above. I add the /Rebuild as the build agents tend to reuse Workspaces, so we need to ensure that the Workspace is clean before we rebuild.

Make the working directory the MSBuildProjectDirectory reserved property, just to avoid arbitrary errors. Here is an example below.

<Target Name="DevEnvInstaller">
<PropertyGroup>
<DevEnv>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com</DevEnv>

<SolutionFile>$(SolutionRoot)\Database\Ispac\SSISPackages.sln</SolutionFile>
<ProjectFile>$(SolutionRoot)\Database\ISPac\SSISPackages\ETLBulkLoader.dtproj</ProjectFile>
<Configuration>Release</Configuration>
</PropertyGroup>
 <Exec>
 Command=""$(devenv)" "$(SolutionFile)" /Rebuild "$(Configuration)" /Project "$(ProjectFile)" /ProjectConfig "$(Configuration)" /Log"
 ContinueOnError="false"
 IgnoreExitCode="false"
 WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>

Ideally, you want to call this target from a reserved task, like AfterGet, so that you control when the target is executed.

<Target Name="AfterGet">
 <CallTarget Targets="DevEnvInstaller">
 </Target>

This now means that you can compile projects in an automated build.