Using DevEnv In MSBuild

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 via the command line. We use as devenv.exe does not provide output, making debugging a chore, and can launch UI, which is far from ideal in a build. With, 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">
<DevEnv>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\</DevEnv>

 Command="&quot;$(devenv)&quot; &quot;$(SolutionFile)&quot; /Rebuild &quot;$(Configuration)&quot; /Project &quot;$(ProjectFile)&quot; /ProjectConfig &quot;$(Configuration)&quot; /Log"
 WorkingDirectory="$(MSBuildProjectDirectory)" />

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">

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

Author: Richie Lee

Full time computer guy, part time runner. Full time Dad, part time blogger. Knows a thing or two about Pokémon. Knows too much about SQL Agent. Writer of fractured sentences. Maker of the best damn macaroni cheese you've ever tasted.

9 thoughts on “Using DevEnv In MSBuild”

  1. Is it possible to achieve the same from PowerShell, I am using devenv to build the mentioned list. Instead if I would like to use MSbuild how can I

  2. I realize this is a really old post and the best solution is to create and use the Microsoft.SqlServer.IntegrationServices.Build.dll. However, I do have access to put that file on the build server for a client and so I am trying your devenv method. Question for you is, do you put these tasks in your *.dtproj file? I tried putting them in a custom Build.proj to call from my build and it is successful, but it does not build anything:

    Microsoft Visual Studio 2013 Version 12.0.31101.0.
    Copyright (C) Microsoft Corp. All rights reserved.
    ========== Build: 0 succeeded or up-to-date, 0 failed, 0 skipped ==========

    1. Hello! Thanks for the comment. It’s 4pm on a Friday in the UK, so I can’t promise a proper response before at least Tuesday morning. However I will take a look and get back to you. You’re problem does ring a bell though!

      1. Hi Richie. I have exactly the same behavior – 0 success, 0 failed, 0 skipped, no other output. Did you remember which bell it was ringing? Cheers Ian

      2. Hi Richie – I’m getting same behavior as Mary building a dot net wrapper project – 0 success, 0 failed, 0 skipped, no other output. Did you remember which ell was ringing? Ian

  3. Hello!

    I never got back to Mary, I’ve just realised this now. So if you’re reading this, apologies Mary!

    I’ve got some free time right now to play around with this. Give me an hour and I’ll try to suss out the problem.

    1. OK right I have sussed out one potential issue. Are you using the same edition of Visual Studio to build it on the build server as you are to develop on locally?

      I have a SSIS solution developed on Visual Studio 2015, but when I try to use 2017 it says

      ” Some errors occurred during migration. For more information, see the migration report:
      ========== Rebuild All: 0 succeeded, 0 failed, 0 skipped ==========”

      This may be the problem.

      FYI, this copy of the MSBuild file will run as one complete build project. Usethe PowerShell underneath to execute the .proj file. Thiswil lsave you having to run builds constantly to debug what the issue is. Just change the values in the PropertyGroup to match your devenv location, sln and dtproj files.

      C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\

      Similarly, change the build file to where you save the file above.


      $msbuild = “C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe”
      $MsBuilExists = Test-Path $msbuild
      If ($MsBuilExists -ne $true) {write-host “msbuild does not exist at this location. Install Visual Studio 2015 (Community Edition should be adequate)”}
      $buildFile = “C:\Users\Richie\Documents\ssis_guy\build_ssis.proj”
      & $msbuild $buildFile

      Let me know if this solves your problem.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s