Monday, April 4, 2011

MSBuild IDEs and Editors

If you frequently create MSBuild Scripts, you may be interested in available IDEs and Editors for creating these MSBuild Scripts.  Amongst some of the most common editors are the following:


  1. Visual Studio with or without add-ins such as Jetbrains Resharper
  2. MSBuild Sidekick--http://attrice.info/msbuild/
  3. SharpDevelop--http://www.icsharpcode.net/OpenSource/SD/Download/
  4. MSBuild Explorer-http://www.msbuildexplorer.com/v2/Install.htm
  5. Enhanced text editors such as EditPlus, EditPad Pro, TextPad, Notepad++ etc.
Let's go through each of the options one by one:

  1. While Visual Studio offers Intellisense for MSBuild, the overall Intellisense is very poor when the schema of the file changes due to extensions such as the MSBuild Extension Pack.  In addition, there is no Intellisense for the use of properties.  This can be remedied through the use of Jetbrains Resharper, however, these is one major flaw which continues to exist in Visual Studio (which has not been resolved yet to my knowledge).  If you use MSBuild as an external tool in Visual Studio, you will encounter unexpected behaviors when passing arguments to the MSBuild file.  This is especially true if you pass several arguments to your MSBuild file.  Given this extremely problematic issue, Visual Studio is probably not a REAL viable option for working with MSBuild files.
  2. While MSBuild Sidekick offers great Intellisense support, it continues to be plagued by numerous problems while refactoring and modifying the build file.  In addition, support for MSBuild Sidekick is practically non-existent and updates to MSBuild Sidekick are few and far between.  The most recent release of MSBuild Sidekick has not been updated in nearly a year.  If you wish to have a reliable development environment for creating MSBuild scripts, MSBuild Sidekick is also not likely to be an option.
  3. SharpDevelop offers Intellisense similar to Visual Studio.  However, it is plagued by issues with passing arguments as well that cause unexpected output behaviors to result.
  4. MSBuild Explorer is a great tool for viewing your MSBuild files, but it is not meant to Edit them as you would expect from most IDEs/Editors.
  5. Finally, an enhanced text editor such as EditPlus for editing and running your build scripts.  While these enhanced text editors offer no Intellisense and little or no syntax highlighting for build script elements, it is actually one of the most reliable means of executing build scripts and happens to be my preferred choice for executing MSBuild Scripts.  Setting up and configuring the MSBuild scripts to run in the editor is extremely easy and painless and passing arguments to the MSBuild script is surprisingly reliable and robust.  In conjunction with the ability to easily capture the output of a build script, debugging and executing build scripts could not be any easier.
Therefore, if you are creating MSBuild Scripts, you are probably best off using an enhanced text editor such as EditPlus (my personally preferred text editor).  However, if you are also like me, you cannot live without Intellisense.  

So what do I do for editing and running my MSBuild scripts?  I use an external editor such as Visual Studio with Resharper, MSBuild Sidekick or SharpDevelop to perform most of the editing of the MSBuild file.  However, once I am satisfied with the changes that I have made, I will open the MSBuild file in EditPlus and then use it to actually execute and run the build script.  If your editor or IDE supports having the file open in more than one editor such as Visual Studio and SharpDevelop, you can bounce back and forth between editing and running the build script.

For those of you who are interested in also using EditPlus as your preferred MSBuild editor of choice, here are the steps to configure EditPlus to run MSBuild:

  1. From the Tools menu, select Configure User Tools
  2. Click on the Add Tool button
  3. For the Menu text, enter something such as "MSBuild"
  4. For the command, browse to the executable path of MSBuild (ex: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe)
  5. For the Argument, select File Path and Prompt.  You may need to surround the File Path with double quotes in order to ensure that spaces are appropriately escaped in the file path (e.g. "$(FilePath)" $(Prompt))
  6. Select the checkbox for "Capture output"
  7. Click OK to save your changes
  8. You will now have an option in your Tools menu for MSBuild
  9. You can now open the MSBuild file of your choice.
  10. Once the file has been opened, simply select MSBuild from your Tools menu and the MSBuild script should execute!

No comments:

Post a Comment