Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

So you’ve just finished creating a lovely shiny new web application. As you’re putting on your jacket, you think ‘Ah! I should quickly create an MSI installer…will only take a few minutes’…you sit back down, and remember the latest company directive that stated that Visual Studio Setup projects should not be used anymore…

No big deal…WIX 3.5 has been released, and is integrated into Visual Studio 2010…easy…

Reality check: no, it’s not quite as easy as you may be used to…so take off your jacket, hang it up, and crack open a can of sugar-free Red Bull before you start playing with WIX.

Don’t get me wrong: WIX is the way to go, but at this point in time if you want to create an installer for a web application you have a lot more work to do than for more traditional applications.

Step 1: Adjusting the Setup Project

So in this example, we have an ASP .NET 4 web application, and have created a WIX installer called MySetup.  We then add a project reference to MyWebApp, and adjust that reference to specify we want to harvest the files:

imageimage

We then make a minor adjustment to the Project.wxs file to specify MyCompany:

Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="d5b59d53-5fbb-4dd4-a2ac-1e97d70710b3" Name="MySetup"
           Language="1033"
           Version="1.0.0.0" Manufacturer="MyCompany"
           UpgradeCode="c72f2c40-88b1-4a8f-8800-1796cf0dbafe">
        <Package InstallerVersion="200" Compressed="yes" />

        <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLLOCATION" Name="MySetup">        
                </Directory>
            </Directory>
        </Directory>

        <Feature Id="ProductFeature" Title="MySetup" Level="1">        
            <ComponentGroupRef Id="Product.Generated" />
        </Feature>
    </Product>
</Wix>

We can then build, and run the generated MSI.  However, at this point we have not put any UI in place, so we end up with our web application installed under Program Files in a folder called MySetup…not ideal, but we’ll get to that later.

If you take a look at the files that have been installed, you will quickly notice a problem: there is no bin folder, and the content of the bin folder has all been put into the root folder:

image

Clearly wrong.  The solution is to adjust the project reference and edit the installer project as explained by Travis Illig in his post How to Consume MSDeploy Staged Web Site Output in a WIX Installer.  After making this adjustments, we now end up with the following result:

image

Excellent. Thanks Travis! Smile

Step 2: Implementing Localisation

You may ask ‘why?’.  Well, aside from the argument about broadening the reach of your product to support other cultures, we can make use of localisation to centralise our text in one place rather than having it spread across various files.  This not only makes maintenance easier, but also makes reuse a whole lot easier.

So add a new WiX Localization File to your project and name it for the main language you are supporting (in my case English.wxl).  We then fill it in with some text we can immediately make use of:

English.wxl
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us"
  xmlns="http://schemas.microsoft.com/wix/2006/localization">
  <String Id="LANG">1033</String>
  <String Id="Comments">MyWebApp Comments</String>
  <String Id="Description">MyWebApp Description</String>
  <String Id="Keywords">MyWebApp</String>
  <String Id="ProductName">MyWebApp</String>
  <String Id="CompanyName">MyCompany</String>  
</WixLocalization>

And adjust our Product.wxs to use the resource entries:

Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="d5b59d53-5fbb-4dd4-a2ac-1e97d70710b3"
           UpgradeCode="c72f2c40-88b1-4a8f-8800-1796cf0dbafe"
           Version="1.0.0.0"
           Name="!(loc.ProductName)"
           Language="!(loc.LANG)"
           Manufacturer="!(loc.CompanyName)">
        <Package InstallerVersion="200" Compressed="yes"
             Languages="!(loc.LANG)"
             Manufacturer="!(loc.CompanyName)" Comments="!(loc.Comments)"
             Description="!(loc.Description)" Keywords="!(loc.Keywords)"/>

        <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLLOCATION" Name="!(loc.ProductName)">        
                </Directory>
            </Directory>
        </Directory>

        <Feature Id="ProductFeature" Title="!(loc.ProductName)" Level="1">
      <ComponentGroupRef Id="MyWebApp_Project" />
            <ComponentGroupRef Id="Product.Generated" />
        </Feature>
    </Product>
</Wix>

You can see how copy-and-paste followed by adjustment is a whole lot easier thanks to localisation, and also avoids string duplication (e.g. ProductName is used multiple times).

In the next post( s) , we’ll look at checking conditions, providing an interface and dealing with IIS.

Print | posted on Sunday, 20 February 2011 12:23 PM

Feedback

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Dave Fowler at 31/03/2011 9:05 PM Gravatar

Hi,

Just a comment on the article " How to Consume MSDeploy Staged Web Site Output in a WIX Installer" - comments are closed on that blog

If your WiX project has several project references with different source directories, the linker may not find the web site files.
This problem can be solved by defining a preprocessor variable to store the path to the PackageTmp folder using a DefineConstants
element in the PropertyGroup and setting the PreprocessorVariable attribute in the HeatDirectory element:

<Target Name="BeforeBuild">
<MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.WebProject)'=='True'" />
<PropertyGroup>
<DefineConstants Condition="'%(ProjectReference.WebProject)'=='True'">
%(ProjectReference.Name).PackageDir=%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\
</DefineConstants>
</PropertyGroup>
<HeatDirectory
OutputFile="%(ProjectReference.Filename).wxs"
Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\"
DirectoryRefId="INSTALLDIR" ComponentGroupName="%(ProjectReference.Filename)_Project"
AutogenerateGuids="true" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true"
ToolPath="$(WixToolPath)"
Condition="'%(ProjectReference.WebProject)'=='True'" Transforms="%(ProjectReference.Filename).xsl"
PreprocessorVariable="var.%(ProjectReference.Name).PackageDir" />
</Target>

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Kuroro at 12/04/2011 7:28 PM Gravatar
Hi! Im having an error about this part:

<ComponentGroupRef Id="MyWebApp_Project" />

in the link that you provided, there is a part there indicating:

"When that target runs, you'll see a .wxs file pop out in the .wixproj project folder. Add the generated .wxs to your .wixproj project so it knows to include it in the build."

I don't see any generated .wxs file... please help.

Im having this error during build.

Unresolved reference to symbol 'WixComponentGroup:MyWebApp_Project' in section 'Product:{60FAA408-70F9-4A32-B04D-673EDAE60F42}'.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Paul at 13/04/2011 8:52 AM Gravatar
Hi Kuroro

At a guess I would say that in your Solution Explorer in VS2010, you do not currently have the Show All Files pressed...when you select this you can see other files in that folder and then add them to your project.

Regards
Paul.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Michael at 3/06/2011 2:54 PM Gravatar
That was so funny, I had the same problem and came across this, I excluded the file and then included it again and it compiled fine :)

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by mightystudent at 29/06/2011 7:39 PM Gravatar
This post is like a spoon-feed way of using WIX 3.5 and and Visual Studio 2010 for creating a web application installer. Its a good idea to post screen shots for cases of misconception. Good work. Cheers!

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by rukia at 21/07/2011 3:02 PM Gravatar
what if in my project, there is no references?

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Azithromycin uses at 30/12/2011 5:55 PM Gravatar
That was so funny, I had the same problem and came across this, I excluded the file and then included it again and it compiled fine

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by pk at 31/01/2012 5:34 PM Gravatar
Hi! Im having an same above error about this part:

<ComponentGroupRef Id="MyWebApp_Project" />

in the link that you provided, there is a part there indicating:

"When that target runs, you'll see a .wxs file pop out in the .wixproj project folder. Add the generated .wxs to your .wixproj project so it knows to include it in the build."

I don't see any generated .wxs file... please help.

Im having this error during build.

Unresolved reference to symbol 'WixComponentGroup:MyWebApp_Project' in section 'Product:{60FAA408-70F9-4A32-B04D-673EDAE60F42}'.


i enabled the VS2010 Show all Files also

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Julius at 15/02/2012 2:22 AM Gravatar
Hi,

This tutorial worked perfectly, until I tried to implement it on our 'real' project where I get trouble from heat.exe;

C:\Program Files (x86)\Windows Installer XML v3.5\bin\Heat.exe dir D:\trunk\Source\CSharp\MyProj\obj\Debug\Package\PackageTmp\ -cg MyProj_Project -dr INSTALLLOCATION -scom -sreg -srd -ag -sfrag -out MyProj.wxs
heat.exe(0,0): error HEAT0321: The harvest type was not found in the list of loaded Heat extensions.
Done building project "Setup.wixproj" -- FAILED.

When I copy and paste the command to the command line it works. When compiling using msbuild from command line everything works.

Any ideas?





# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Julius at 17/02/2012 8:44 PM Gravatar
Any tips on creating a database with intergrated security login using the idendity of the apppool?

I'm getting stuck where this guy is getting stuck;
stackoverflow.com/...

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by novo 7 at 20/02/2012 7:58 PM Gravatar
nice post,thanks for sharing! BTW,check out my new android 4.0 tablet

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by buy research paper at 27/03/2012 5:04 PM Gravatar
i like your awesome information

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Register a website at 18/04/2012 9:45 PM Gravatar
I have enjoyed a lot by reading your blog. You have taught me very well. Really good to be here. Thanks for sharing.

# Great

left by essay writing help at 18/06/2012 6:21 PM Gravatar
This kind of blog always useful for blog readers, it helps people during research. your post is one of the same for blog readers.

# hormone doctors

left by hormone doctors at 27/06/2012 2:16 PM Gravatar
I have just bookmarked this site for future reference. Thanks for posting such informative content. I will keep visiting this blog very often.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Buy essays at 7/07/2012 4:39 PM Gravatar
This is the perfect blog for anyone who wants to know about this topic. You know so about this topic.

# excel support

left by click here at 6/09/2012 3:51 PM Gravatar
Your listings provide a clear note of creating Web application Installer with Windows Installer XML (wix) 3.5 and visual studio 2010. It is very commendable that you give explanations further in part 2 regarding the application of general settings and checking of prerequisites.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Colin at 19/09/2012 7:04 AM Gravatar
remember thsis is good news folks

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by studying-abroad.com at 19/09/2012 9:37 PM Gravatar
Here is a pretty good post that explains with details on how to create a web application installer. The article emphasizes even on the small details and is a great relief for people who are not a techie like me.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by powerpoint troubleshooting at 27/09/2012 9:41 PM Gravatar
Well integration of Wix 3.5 into Visual Studio! Wix installer setup is arranged in a good manner, so you don’t face any problem in following the step. The Windows Installer XML project system enables features such as source code control integration and other Visual Studio project system features.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Cebu travels at 10/11/2012 12:20 PM Gravatar
Well done I really love your blog it help me a lot this time. The details are well done, It is pretty good and i really appreciate this.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by coach purses outlet at 24/11/2012 3:22 AM Gravatar
Well done I really love your blog it help me a lot this time. The details are well done, It is pretty good and i really appreciate this.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by MLA essay at 24/11/2012 5:45 AM Gravatar
Nice post. Thanks for sharing useful information.

# cheap coach handbags

left by cheap coach handbags at 26/11/2012 4:36 PM Gravatar
This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it….

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by coach outlet online at 26/11/2012 4:40 PM Gravatar
The details are well done, It is pretty good and i really appreciate this.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by coach outlet at 26/11/2012 8:15 PM Gravatar
Nice post. Thanks for sharing useful information.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by research proposal writing at 17/03/2013 3:52 PM Gravatar
I am very grateful that I can learn so very much from your website. Thank you for that.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by go here at 10/04/2013 5:02 PM Gravatar
The website shows the various steps to be followed while creating web application installer with wix 3.5 has been a very good experience to read on with. Many of the readers might have been in search of this article and the information will be useful for them

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Alicia at 12/04/2013 10:09 PM Gravatar
Hi Paul , Great Article , exactly what im looking for but having a little difficulty with Wix version 3.6 , i wonder if you can help.

Using the latest version of Wix 3.6 so the wsx file looks a little different to the one above , the main thing being the Fragement nodes that seem to come with 3.6.
I have tried adding a refernece to my web app and setting the harvest to true as in the example and it builds fine and creates my msi , but when i go to install it doesnt install anything to my programfiles.It just exits the installer.

Is there some extra step you need to do for version 3.6 to get it to install the web application components ?

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Social Bookmarks at 24/04/2013 6:48 PM Gravatar
I am really enjoying the theme/design of your blog. Do you ever run into any browser compatibility issues? A number of my blog audience have complained about my site not operating correctly in Explorer but looks great in Safari. Do you have any suggestions to help fix this issue?

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Dubai Web Design Companies at 25/04/2013 5:14 PM Gravatar
This all info is very impressive, you have done hard work for this topic. you have explain this work very deeply.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Mont Blanc Pens UK at 5/05/2013 2:31 PM Gravatar
This information and facts are very impressive, you have done persistence for this particular issue. you got talk about the work terribly substantially.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by obat kuat at 20/05/2013 5:49 AM Gravatar
Your post was really very attractive that's why my heart ask me to do comments & i do so Fantastic work you have done & you should carry on.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Fees For Real Estate Agents at 21/05/2013 5:08 AM Gravatar
I think this is among the most vital information for me. And i'm glad reading your article. But wanna remark on some general things, The site style is great, the articles is really nice : D. Good job, cheers

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Holen Sie sich die Fakten at 23/05/2013 11:24 AM Gravatar
wow this realy helped me with my problem. thanks for sharing this information with us. i'll share it with my friends.

# cheap oakley sunglasses

left by cheap oakley sunglasses at 28/05/2013 11:20 AM Gravatar
Thank you for sharing

# nice one

left by Visit Website at 27/06/2013 4:54 AM Gravatar
I have enjoyed a lot by reading your blog. You have taught me very well. Really good to be here. Thanks for sharing.

# nice one

left by Visit Website at 27/06/2013 4:55 AM Gravatar
thank you

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Hier klicken at 23/08/2013 5:55 PM Gravatar
Thanks for sharing this content, I have been trying to create a we application installer, I do not know what to use yet, but this website is helping me deicide what to use.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by escort crawley at 26/08/2013 9:43 PM Gravatar
I always searching for it, much time I search this on internet but I not get the perfect answer for this question. But your blog solve my all problem. Thanks for this useful post.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by online slots at 5/10/2013 4:18 PM Gravatar
Your article is certainly relevant and useful to each user. Thank you for revealing this information, I had never thought that things could be so simple. An example of your work and the result allows me to see more specifically where I grow professionally.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by a delighted soul at 1/11/2013 9:57 AM Gravatar
Excellent writeup, very easy to follow and definitely something I really needed. I'm a programmer of sorts, so this will help me out a great deal, speed up a pivotal aspect of the process, and also help me with other things.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by webmaster at 1/11/2013 11:56 PM Gravatar
The process looks simple enough, I'll be sure to put it to use. I think it'll come in handy when creating installers for registry edit files and others of that like. I'm not exactly developing my own applications as of now, but who knows?

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by noticias at 11/11/2013 4:28 AM Gravatar
Trying to follow your instructions. But I don't understand where all the !(loc.whatever) variables are coming from. None of the files in your solution contain anything that seems to define those values. Am I missing something here?

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by www.goldenkudocasino.com at 30/11/2013 3:30 PM Gravatar
This site seems to get a good amount of visitors. Congratulation. Keep up the good work.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Web Design Dubai at 11/12/2013 6:18 PM Gravatar
Nice share mate.

# re: Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1

left by Hsingh at 14/01/2014 1:07 AM Gravatar
This is a great piece of work and superb explanation. I have ran into few error Would expect your help.

1. I have followed the above word by word , when installing my application it just aborts in the middle . Looking at the .msi log I found the following :-
Action start 13:01:39: InstallInitialize.
Action ended 13:01:39: InstallInitialize. Return value 3.
Action ended 13:01:39: INSTALL. Return value 3.

2. My second question if where is "Product.Generated" in <ComponentGroupRef Id="Product.Generated" /> is defined

Any help specially for my first point would be great.
Title  
Name
Email (never displayed)
Url
Comments   
Please add 7 and 7 and type the answer here: