{"id":2393,"date":"2006-03-15T21:13:00","date_gmt":"2006-03-15T21:13:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2006\/03\/15\/building-with-wix-targets\/"},"modified":"2006-03-15T21:13:00","modified_gmt":"2006-03-15T21:13:00","slug":"building-with-wix-targets","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/building-with-wix-targets\/","title":{"rendered":"Building with Wix.Targets"},"content":{"rendered":"<p>I&#8217;ve been away for a while working on a high priority issue that I&#8217;ll discuss in detail soon, as well as investigating a common issue regarding 32- and 64-bit installations about which I&#8217;ll write a new series of posts. For much of that work I&#8217;ve been using Windows Installer XML, or <a href=\"http:\/\/wix.sourceforge.net\/\">WIX<\/a>, which allows me to build Windows Installer packages, merge modules, and patches (actually, just the <i>.pcp<\/i> files as input to <i>PatchWiz.dll<\/i>) using XML with support for preprocessor directives. You can find out more about WIX at <a href=\"http:\/\/wix.sourceforge.net\/\">http:\/\/wix.sourceforge.net\/<\/a>, as well as from Rob Mensching&#8217;s <a href=\"\/robmen\/\">blog<\/a>, who is the creator and &#8220;<a href=\"\/robmen\/archive\/2004\/04\/14\/112970.aspx\">benevolent dictator<\/a>&#8221; of WIX.<\/p>\n<p>More recent <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=105970&amp;package_id=114109&amp;release_id=386880\">distributions<\/a> starting with build 2.0.3719.0 will include a file named <i>wix.targets<\/i>, which is a file you can include into an <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/wea2sca5(VS.80).aspx\">MSBuild<\/a> project. MSBuild uses XML configuration files, similar to <a href=\"http:\/\/ant.apache.org\/\">Ant<\/a> and all its variants like <a href=\"http:\/\/nant.sourceforge.net\/\">NAnt<\/a>, to build projects. You can import <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms164312(VS.80).aspx\"><i>.Targets<\/i> files<\/a> (extension is meaningless, really) using the <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/92x05xfs(VS.80).aspx\"><code>&lt;Import&gt;<\/code><\/a> element and take advantage of the properties, tasks, and more that are imported. The <i>wix.targets<\/i> file defines several new tasks that correspond to <i>candle.exe<\/i> and <i>light.exe<\/i>, the compiler and linker in WIX, respectively.<\/p>\n<p>At the top of the <i>wix.targets<\/i> file is a target named CheckRequiredProperties. That makes sure that you&#8217;ve specified both an OutputName and an OutputType property, as shown below:<\/p>\n<p><font face=\"monospace\">&lt;PropertyGroup&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;OutputName&gt;Example&lt;\/OutputName&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;OutputType&gt;package&lt;\/OutputType&gt;<br \/>&lt;\/PropertyGroup&gt;<\/font><\/p>\n<p>This will create a file names <i>Example.msi<\/i>. After defining those properties you must import the <i>wix.targets<\/i> file:<\/p>\n<p><font face=\"monospace\">&lt;Import Project=&#8221;wix.targets&#8221;\/&gt;<\/font><\/p>\n<p>Then it&#8217;s just a matter of calling the targets defined in <i>wix.targets<\/i>, such as Build, which will set up, compile, and link. That didn&#8217;t work, though. The call to <i>candle.exe<\/i> was missing an input file. I couldn&#8217;t find any more required properties and I&#8217;m still trying to learn MSBuild, since after using NAnt for so long I wasn&#8217;t all too familiar with what was yet needed. I read the skimpy documentation and searched the Internet, but found nothing useful (one reason I&#8217;m posting this). So I talked to my colleague who has been working on <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=59384\">MSBee<\/a>.<\/p>\n<p><a href=\"\/clichten\/\">Craig<\/a> pointed out that the input <code>@(Compile)<\/code> was needed and that I could use an <code>&lt;ItemGroup&gt;<\/code> to define input source files. So, the final MSBuild project file that would compile <i>Example.wxs<\/i> and link the output as <i>Example.msi<\/i> would look like the following:<\/p>\n<p><font face=\"monospace\">&lt;Project DefaultTargets=&#8221;All&#8221; xmlns=&#8221;http:\/\/schemas.microsoft.com\/developer\/msbuild\/2003&#8243;&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;PropertyGroup&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;OutputName&gt;Example&lt;\/OutputName&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;OutputType&gt;package&lt;\/OutputType&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/PropertyGroup&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Import Project=&#8221;wix.targets&#8221;\/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;ItemGroup&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Compile Include=&#8221;Example.wxs&#8221;\/&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/ItemGroup&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Target Name=&#8221;All&#8221; DependsOnTargets=&#8221;Build&#8221;\/&gt;<br \/>&lt;\/Project&gt;<\/font><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been away for a while working on a high priority issue that I&#8217;ll discuss in detail soon, as well as investigating a common issue regarding 32- and 64-bit installations about which I&#8217;ll write a new series of posts. For much of that work I&#8217;ve been using Windows Installer XML, or WIX, which allows me [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-2393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-installation"],"acf":[],"blog_post_summary":"<p>I&#8217;ve been away for a while working on a high priority issue that I&#8217;ll discuss in detail soon, as well as investigating a common issue regarding 32- and 64-bit installations about which I&#8217;ll write a new series of posts. For much of that work I&#8217;ve been using Windows Installer XML, or WIX, which allows me [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=2393"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=2393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=2393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=2393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}