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:

1
$(var.PRODUCTVERSION)

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):

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

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

1
2
3
<MSBuild Projects="$(PathToProjectFolder)\YourProject.wixproj"
         Properties="PRODUCTVERSION=$(YourProductVersion)"
   />

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 founder of Bad Echo LLC, which offers consulting services to clients who need an expert in C#, WPF, Outlook, and other advanced .NET related areas. I enjoy well-designed code, independent thought, and the application of rationality in general. You can reach me at matt@badecho.com.

  14 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!
    Thanks!!

  3. Hi,

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

  4. … [Trackback]…

    [...] Read More here: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  5. … [Trackback]…

    [...] Read More on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  6. … [Trackback]…

    [...] Find More on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  7. … [Trackback]…

    [...] There you can find 75049 additional Information on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  8. … [Trackback]…

    [...] Read More on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  9. … [Trackback]…

    [...] Read More here to that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  10. … [Trackback]…

    [...] Read More Information here to that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  11. … [Trackback]…

    [...] Here you will find 2560 additional Info to that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  12. … [Trackback]…

    [...] Info on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  13. … [Trackback]…

    [...] Find More Info here on that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

  14. … [Trackback]…

    [...] Read More here to that Topic: badecho.com/2011/09/automating-wix-with-msbuild [...]…

 Leave a Reply

(required)

(required)

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.