Wix Installation Deployment Tutorial (iv) Add installation files and shortcuts

Source: Internet
Author: User

With the introduction of the previous three articles, we should also have some understanding of the XML deployment of WiX, the weather is good today, another one. The main introduction of desktop, Start menu, uninstall and other functions of how to add. Hope that the Garden friends support!

First, how to add files

Demo Packager is very simple, just an EXE, but the actual process, often also refer to some DLLs, configuration files. How do we install it under the target file? This is more troublesome than Windows Installer, just add a reference directly to Windows Installer. But WiX is not a hassle, first of all to understand the role of each element, directory defines the installation directory, Componentgroup and Directoryref contains the component and file definition files of the true path. Then feature is an installation checklist that tells WiX which files to install. We tried to add a file to the installation directory, put in a DLL and an XML file.

1. Create a new folder in the WiX project and copy the files that we need to pack in.

2. Modify the destination folder again. Add a id= "Demo" directory under Setup07

  <Fragment>    <directory id= "TARGETDIR" name= "SourceDir" >      <directory id= "ProgramFilesFolder" >        <directory id= "Installfolder" name= "Setup07" >          <directory id= "Demo" Name= "Demo"/>        < /directory>      </Directory>    </Directory>  </Fragment>

3. Define the location of the files that need to be added. In the framment element block. Add an DRIECTORYREF element with ID pointing to the demo,

  <Fragment>    <componentgroup id= "productcomponents" directory= "Installfolder" >      <component Id = "Productcomponent" >        <file id= "MyApplication.exe"  source= "$ (var. Myapplication.targetpath) "/>      </Component>    </ComponentGroup>   <directoryref id=" Demo ">     <component id=" Variable.xml "guid=" 5e254682-dd5f-453d-8333-844457282026 ">      <file Id=" Variable.xml "  source=" Content/variable.xml "/>      <file id=" Mydll "source="  content/ CxIODrvWrapper.dll "/>      </Component>   </DirectoryRef>  </Fragment>

As we can see, for Componentgroup, the Dirctory property is used directly installfolder to the directory in the previous fragment. All of his files can be installed under the Setup07 folder. The ID of our directoryref points to the demo folder we created, to illustrate the meaning of the component installation component, which must correspond to the feature element and which can contain more than one file. Then modify our feature element. Add a paragraph. For the GUID, directly in the VS-tool-create the GUID and then copy it out on the line. Do not have to be so generated every time, the production of random change a few numbers can also be done.

  <componentref id= "Variable.xml"/>

This componentref directly corresponds to the element of the component with ID Variable.xml, telling WiX to install one of these components. This allows the build to be installed. DLL and XML files can be seen in your C:\Program files (x86) \setup07\demo directory.

The above componentgroup can also be broken. The same effect.

View Code

Second, add the menu bar shortcut

Let's first add a shortcut to the menu bar

1. In the install directory fragment element, add a directory. Remember this to insert in <directory id= "TARGETDIR" name= "SourceDir" > below.

<directory id= "ProgramMenuFolder" >        <directory id= "Applicationprogramsfolder" name= "WixSetUp"/> </Directory>

The programmenufolder here is just the Start menu for Windows, and the second level of directory is the file to be displayed in the menu, named Wixsetup.

2. After we add the shortcut to this directory, we need to use the directoryref element. Shortcut is the element that generates the shortcut.

<directoryref id= "Applicationprogramsfolder" >      <component id= "Applicationshortcut" Guid= " 5a254682-dd5f-453d-8333-144457282026 ">        <shortcut id=" applicationstartmenushortcut "                  Name=" Mysetup "                  description= "My first application installed by WiX"                  target= "[Installfolder]myapplication.exe"                  workingdirectory= "Installfolder"/>        <removefolder Id= " Applicationprogramsfolder "on=" Uninstall "/>        <registryvalue root=" HKCU "key=" software\microsoft\ Myapplicationname "name=" Installed "type=" integer "value=" 1 "keypath=" yes "/>      </Component>    </ Directoryref>

It should be stated that the target is written to the EXE in our installation directory, the ID of the directory is added to the brackets, followed by the name of the application. Here the Removefolder and registry elements, the official document said to avoid the ice validation errors in combination with the shortcut appear, I also a bit dizzy, can only be added first. Interested can look at the explanation of this verification here http://msdn.microsoft.com/en-us/library/aa368942.aspx. VS generates an error, all from the beginning of the ice.

Finally we add a list of component in the feature.

<componentref id= "Applicationshortcut"/>

After the build is compiled, the Wixsetup/mysetup directory will appear in our menu bar when the installation is complete. Open can run, but this time the icon of the shortcut has not changed, first remember this question, and then continue to go down.

Recently found a strange problem, need to make shortcuts to the EXE, their ID must and file always, otherwise this shortcut will not find this exe after installation.

   <shortcut id= "Desktopshortcut" directory= "Desktopfolder"   name= "Runtime" target= "[ Dire77f08c3a4be230b19f4d6c90a249e4f]hmirun.exe "                   workingdirectory=" dire77f08c3a4be230b19f4d6c90a249e4f "Icon = "Startshorcut"/>  <shortcut id= "DesktopShortcut2" directory= "Desktopfolder"   name= "Sacaddev" target= "[Installfolder]SCADAFramework.exe"              workingdirectory= "Installfolder" icon= "Devshorcut"/>         
....
<file source= ' $ (var. Dev) Hmirun\hmirun.exe ' id= ' HMIRun.exe '/>

And if you switch to an encrypted ID, you can't find it.

At this point the full code is as follows

View Code

Third, add Web pages and uninstall shortcuts

On the base of the menu bar, add a Web shortcut that jumps to your portal site. Takes 3 steps

1. First introduce WixUtilExtension.dll this is not much to say (previously quoted).

2. Add this extension to the project's namespace. This is equivalent to the using of C #.

<wix xmlns= "Http://schemas.microsoft.com/wix/2006/wi"  xmlns:util= "http://schemas.microsoft.com/wix/ Utilextension ">

3. In the second component, add

    <util:internetshortcut id= "Onlinedocumentationshortcut"               name= "Online"                      target= "Http://yourWebsit/Home /index "/>

And the previous shortcut at the same level. This will be OK. Install one more online shortcut and click Jump to the specified page.

Let's add a shortcut to the uninstallation, and now we just need a shortcut, id uninstproduct.

    <shortcut id= "uninstallproduct"                          name= "Uninstall"                          description= "uninstalls My application"                          target= "[ Systemfolder]msiexec.exe "                          arguments="/x [ProductCode] "/>

Target points to Msiexec.exe this is the program that is actually performing the uninstallation, [Systemfolder] corresponds to its location. Argument tells it through ProductCode which is the program to uninstall. /x is the unload command and it's almost done here. But the previous icon did not change over. Here, add an icon to the first shortcut. Revision changed to

  <shortcut id= "Applicationstartmenushortcut"                  name= "Mysetup                  " icon= "MyApplicationIcon.exe" Description= "My first application installed by WiX"                  target= "[Installfolder]myapplication.exe]                  workingdirectory= "Installfolder" >          <icon id= "MyApplicationIcon.exe" sourcefile= "content/ MyApplicationIcon.exe.ico "/>        </Shortcut>

An icon attribute and element are added to this interior. ID named when the proposed add an icon, and then the ICO icon made, you can find online. This piece of code is as follows

View Code

As follows: There are three icons in the Start menu bar, the first one is our application, and this ico looks a little blurry. Online and uninstalled icons are default, no modifications

Iv. adding desktop shortcuts

Now we have a shortcut to the desktop. After a few attempts, or the whole came out.

1. You need to add a file directory first, which represents the re-desktop.

    <directory id= "Desktopfolder" name= "Desktop"/>

2. Add shortcut, this shortcut can not be written in the previous place, because it is the menu bar. Must use Directoryref, but icon can still use the same

<directoryref id= "Desktopfolder" >      <component id= "Desktopfoldershortcut" guid= " 5a254682-dd1f-453d-8333-144457282026 ">        <shortcut id=" desktopshortcut "directory=" DesktopFolder   " Name= "MyApplication" target= "[Installfolder]myapplication.exe"  workingdirectory= "Installfolder" Icon= " MyIcon.exe ">        </Shortcut>      <registryvalue root=" HKCU "key=" software\microsoft\ Myapplicationname "name=" Installed "type=" integer "value=" 1 "keypath=" yes "/>      </Component>    </ Directoryref>

Note that the following registryvalue do not add, and indeed Icexx .... Error. Need to register a bit. In this way, the installation is compiled, the desktop appears a shortcut, the program runs, the icon under the Windows window has changed, is no longer the default Windo program icon.

Transferred from: http://www.cnblogs.com/stoneniqiu/p/3365017.html

Wix Installation Deployment Tutorial (iv) Add installation files and shortcuts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.