A user comment recently alerted me to the need to update a past article I wrote on integrating MSBuild and WiX so that one might achieve build automation with WiX. My previous article was written a long time ago, and probably was done before actually implementing the process in practice.

How I actually integrated WiX with MSBuild in the real world will be shown in this post.

Let’s assume you want to set up WiX so that MSBuild can pass some variables to it (a good example being the product version; let’s assign that to a constant named PRODUCTVERSION).

In your WiX source, you’d reference that passed-in product version using:


To get that to work, the first thing I do is edit the *.wixproj file itself. Place the following somewhere in the file (mine is at the bottom about):

    <Target Name="BeforeBuild">
        <CreateProperty Condition="$(PRODUCTVERSION) != ''" Value="PRODUCTVERSION=$(PRODUCTVERSION);$(DefineConstants)">
            <Output TaskParameter="Value" PropertyName="DefineConstants" />

Then, in your msbuild/team build script, you can build the WiX project and pass in the product version like so:

     <MSBuild Projects="$(PathToProjectFolder)\YourProject.wixproj"

Naturally, you need to define the “PathToProjectFolder” and “YourProductVersion” somewhere.

Also, if you want to pass additional properties, they should be semicolon delimited when setting the “Properties” attribute.

Matt Weber

I'm the the Senior Software Architect at Emergingsoft where I lead the software development team. I am also the owner of this website. I enjoy well-designed code, independent thought, and the application of rationality in general. You can reach me at matt@badecho.com.

  3 Responses to “Automating WiX with MSBuild”

  1. Hi nice article,

    excepting more like this…Matt weber

  2. This was exactly what I needed and it worked perfectly!

  3. Hi,

    Great article ! Thanks for sharing.. It really helped me to get through a situation..

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2012-2013 Matt Weber. All Rights Reserved. Terms of Use.