Showing posts with label wix. Show all posts
Showing posts with label wix. Show all posts

Wednesday, January 31, 2018

[Solution] Visual Studio doesn't release WiX Extension DLL file


Monday, June 24, 2013

Wix: how to apply special access rights to a directory

Use <CreateFolder> and <util:PermissionEx> tags.

Don't forget to add "-ext WixUtilExtension" parameter to "candle" and "light" command lines.

User needs to run installer under administrative account.

Example below gives every user generic access to application directory.


<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
 xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
 
    <Product ... />
    
    ...
    
    <Directory Id='AppFolder' Name='My Application'>
        <Component Id='AppFolder' Guid='AC84FDFDA-F8D5-4DEF-8A68-5D8809E818D8'>
            <CreateFolder>
                <util:PermissionEx User="Everyone" GenericAll="yes"/>
            </CreateFolder>
            <File ... />
            <File ... />
            <RemoveFolder Id='AppFolder' On='uninstall' />
        </Component>
    </Directory>

...


Thursday, June 20, 2013

WiX: how to install and start Windows service running under LocalSystem account

Tip 1: Separate service under own <Component> tag.

Tip 2: Don't forget to include this <Component> into <Feature> tag.

Tip 3: Mark service executable <File> tag with KeyPath='yes' attribute.

Tip 4: If you want to configure user access rights for this service, include <util:PermissionEx> tag.

Tip 4.1: Don't forget to include "xmlns:util" namespace into <Wix> tag.

Tip 4.2: Don't forget to add "-ext WixUtilExtension" parameter to "candle" and "light" command lines.

Tip 5: User needs to run installer under administrative account to be able to install service under LocalSystem account.

Real example
  • installs and starts service on installation;
  • stops and removes service on uninstallation.

myapplication.wxs

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
 xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>

    <Product ... >

        <Package ... />

        <Directory Id='TARGETDIR' Name='SourceDir'>

            <Directory Id='INSTALLDIR' Name='MyApplication'>
            
                    <Component Id='MyService' Guid='2575CFDC-5F26-4D81-BCD3-81F4209B7CAD'>
                        <File Id='MyService.exe' Name='MyService.exe' Source='MyService.exe' DiskId='1' KeyPath='yes' />
                        <ServiceInstall Id="MyService" Type="ownProcess" Name="MyService" DisplayName="MyService display name"
                                Description="MyService description" Start="auto" Account="LocalSystem" ErrorControl="normal">
                            <util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes"
                                    ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" />                                
                        </ServiceInstall>
                        <ServiceControl Id="MyService" Start="install" Stop="both" Remove="both" Name="MyService" Wait="no" />                                
                    </Component>

                    ...
                    
            </Directory>

        </Directory>
        
  <Feature Id='Complete' Level='1'>
            ...
   <ComponentRef Id='MyService' />
            ...
  </Feature>

    </Product>

</Wix>

build.bat

candle.exe myapplication.wxs -ext WixUtilExtension
light.exe myapplication.wixobj -ext WixUIExtension -ext WixUtilExtension

Thursday, April 18, 2013

WiX: How to read product version from .EXE or .DLL file

Let's assume that my program has MyCoolestApplication.exe as the main executable file name.

Using bind.FileVersion syntax I can define a VERSION variable that will automatically get product version from .EXE file:
<?xml version='1.0' encoding='windows-1252'?>

<?define PRODUCT="My coolest application"?>
<?define VERSION=!(bind.FileVersion.MyCoolestApplication.exe)?>

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

    <Product Name='$(var.PRODUCT) $(var.VERSION)' Version='$(var.VERSION)' Id='NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN'
        UpgradeCode='NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN' Language='1033' Codepage='1252' Manufacturer='Vurdalakov'>

    ...