Set shortcut targetpath Wix - wix

I want to set the shortcut target path in wix for an advertised shortcut
This is the code that creates the shorcut now:
<Component Id="APP_EXE" Directory="INSTALLDIR" DiskId="1" Guid="XXXX-XXXX">
<File Id="AppExe" Name="app.exe" Source="$(var.ComponentSourceDir)\$(var.ExeName)" KeyPath="yes">
<Shortcut Id="desktopShortcut" Advertise="yes" Directory="DesktopFolder" Name="$(var.VersionedName)" WorkingDirectory="INSTALLDIR" Icon="MainIcon.exe" IconIndex="0" />
</File>
</Component>
The target in shortcut properties window is readonly now and it displayes the application name. I cannot change it.

I created a new component where I create the shortcut. I removed the previous one.
<Component Id="APP_EXE" Directory="INSTALLDIR" DiskId="1" Guid="XXXX-XXXX">
<File Id="AppExe" Name="app.exe" Source="$(var.ComponentSourceDir)\$(var.ExeName)" KeyPath="yes">
</File>
</Component>
<Component Id="APP_SHORTCUT" Directory="INSTALLDIR" DiskId="1" Guid="XXXX_XXXXX">
<RegistryValue Root="HKCU" Key="Software\APP\Installer" Name="desktopShortcut" Value="KeyPath" KeyPath="yes" Type="string" />
<Shortcut Id="desktopShortcut" Directory="DesktopFolder" Name="$(var.VersionedName)" WorkingDirectory="INSTALLDIR" Icon="MainIcon.exe" IconIndex="0" Target="[INSTALLDIR]app.exe"/>
</Component>

Related

Wix recreate deleted shortcut when reinstalling

I'm learning about shortcuts in Wix and have managed to create shortcuts on the desktop.
If I delete the shortcut and then run the installer again I would like the shortcut to be created again.
How can this behavior be achieved with Wix?
I have created shortcuts both with
<File Id="TestX.exe" Name="TestX.exe" Source="$(var.TestX_TargetDir)TestX.exe">
<Shortcut Id="desktopIcon" Directory="DesktopFolder" Name="TestX" WorkingDirectory='INSTALLFOLDER' Icon="IconTestX.exe" IconIndex="0" Advertise="yes" />
</File>
and
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut"
Guid="1E0D1741-57F0-4E22-89FC-4A189E2BB7E0">
<Shortcut Id="desktopSC"
Name="MyProduct"
Description="MyProduct description"
Target="[INSTALLFOLDER]TestX.exe"
Icon="IconTestX.exe">
</Shortcut>
<RemoveFolder Id="RemoveDesktopFolder"
Directory="DesktopFolder"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
I solved this problem by using WixUI_InstallDir in the WixUI library, which added a GUI which includes the option to start a repair.
Links about the WixUI dialog library:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html
http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html

Create shortcuts depending on ALLUSERS value

My installer works fine for installing to Program Files or AppData depending on the ALLUSERS value (which is set by the user). However, I can't get the icons to distribute to all users when ALLUSERS is set to 1 - currently they only show for the current user.
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Component Id="File1.exe" Guid="*">
<File Id="File1.exe" Name="File1.exe" DiskId="1" KeyPath="yes"
Source="Content\File1.exe" />
</Component>
</DirectoryRef>
<DirectoryRef Id="TARGETDIR">
<Component Id="shortcutFile1" Guid="*">
<Shortcut Id="shortcutFile1" Name="File1"
Target="[INSTALLDIR]File1.exe"
Directory="StartMenuAppFolder" Show="normal" />
<RemoveFolder Id="removeStartMenuAppFolder"
Directory="StartMenuAppFolder"
On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\MyApp\shortcutID_0001"
KeyPath="yes" Type="string" Value="" />
</Component>
</DirectoryRef>
</Fragment>
Any help would be appreciated.

WiX missing 'Start In' property in desktop shortcut

I am working with WiX from last 5 month with no issues. Recently, i am in need to have "StartIn" property in App Desktop shortcut. By default, its empty.
Here is my full Installer code.
I am working with below code:
<Component Id="myapplication.EXE" DiskId="1" Guid="*">
<File Id="myapplication.EXE" Name="My Application.exe"
Source="D:\My Application\My Application.exe">
<Shortcut Id="desktopShortcut" Directory="DesktopFolder"
Name="My Application" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
<Shortcut Id="ExeShortcut" Directory="ProgramMenuDir"
Name="My Application" Icon="StartMenuIcon.exe" IconIndex="0" />
</File>
</Component>
But didn't work.
I have also tried adding "Target" property:
<Shortcut Target= "INSTALLDIR" Id="desktopShortcut" Directory="DesktopFolder"
Name="Virtual Sim Center Beta" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
but getting error message:
The Shortcut/#Target attribute cannot be specified when the Shortcut
element is nested underneath a File element.
This script bellow is working for my WIX:
....
<!-- Desktop Menu -->
<DirectoryRef Id="DesktopFolder">
<Component Id="FooDesktopShortcutMenu" Guid="*">
<Shortcut Id="FooApplicationDesktopShortcut"
Name="Foo Application"
Description="The Foo is Cool!"
Target="[#FooMainApp]"
WorkingDirectory="INSTALLFOLDER"
Directory="DesktopFolder"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\FooApplication"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
....
<!-- Tell Wix -->
<Feature Id="ProductFeature" Title="FooSetup" Level="1">
.....
<ComponentRef Id="FooDesktopShortcutMenu"/>
.....
</Feature>
.....
Glytzhkof is right and so is your WiX source - just put it under the Component.
In addition to the answer by #Adiono check whether the 'WorkingDirectory' folder actually contains the 'Target'.
The 'Start in' of my shortcut was blank even when both 'WorkingDirectory' and 'Target' had valid values, but the 'Target' was not present in the 'WorkingDirectory'.
I don't have Wix set up to try this, but you can try to move the Shortcut element up to be nested under the Component element and not the File element. Then set the WorkingFolder attribute. Try something like this.

Shortcut Target is set to keyPath instead of parent file? (WIX documentation is wrong)

WIX documentatino on Shortcut element says about Target attribute:
The value will be defaulted to the parent File when nested under a File element.
But the code
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll" KeyPath="yes" />
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
does not work as expected - shortcut points to dll file and running it shows Windwos error message that it can't launch file with dll extention.
To fix that we need to make the only difference: set KeyPath="yes" attribute for exe file instead of dll:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
So WIX documentation contains mistake? Target is set not to the parent File element, but to the ancestor's Component's KeyPath?
Or is it my mistake and something wrong with my code?
Try to add a <RegistryValue> tag like this:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\setup" Name="Shortcut" Type="integer" Value="1" KeyPath="yes" />
</Component>
If your InstallScope is perUser, using HKCU
If your InstallScope is perMachine, using HKLM

WiX major upgrade refuses to replace existing file!

EDIT!
It's rough how a question on here seems to get seen when first posted, but when a question is asked, and then answered, for me it seems abandoned. I am still having this problem, and not sure what to do.
Hello! I have inherited this project with a WiX installer, and am required to make this version usefully upgrade the previous one! My problem comes in replacing the database files with new versions. No, the problem is not that they are locked, I can replace them manually, and in fact now ONE of them is replaced, while the other is not. Please, please tell me what I'm doing wrong here. I've tried several other solutions (including registry keys as KeyPath instead of CompanionFile) but nothing is quite working.
Here is (most of) the code of the .WXS file:
<Product Id='$(var.ProductCode)'
UpgradeCode='$(var.UpgradeCode)'
Name="Pathways"
Version='$(var.ProductVersion)'
Manufacturer='$(var.Manufacturer)'
Language='1033'>
<Package Id="*"
Description="Pathways Directory Software"
InstallerVersion="301"
Compressed="yes" />
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
<Media Id="1" Cabinet="Pathways.cab" EmbedCab="yes" />
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion
OnlyDetect="no"
Maximum="$(var.ProductVersion)"
IncludeMaximum="no"
Language="1033"
Property="OLDAPPFOUND"
/>
<UpgradeVersion
Minimum="$(var.ProductVersion)"
IncludeMinimum="yes"
OnlyDetect="no"
Language="1033"
Property="NEWAPPFOUND"
/>
</Upgrade>
<Property Id="ALLUSERS">2</Property>
<!-- directories -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- program files directory -->
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Pathways"/>
</Directory>
<!-- application data directory -->
<Directory Id="CommonAppDataFolder" Name="CommonAppData">
<Directory Id="CommonAppDataPathways" Name="Pathways" />
</Directory>
<!-- start menu program directory -->
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramsMenuPathwaysFolder" Name="Pathways" />
</Directory>
<!-- desktop directory -->
<Directory Id="DesktopFolder" />
</Directory>
<Icon Id="PathwaysIcon" SourceFile="\\Fileserver\Release\Pathways\Latest\Release\Pathways.exe" />
<!-- components in the reference to the install directory -->
<DirectoryRef Id="INSTALLDIR">
<Component Id="Application" Guid="EEE4EB55-A515-4872-A4A5-06D6AB4A06A6">
<File Id="pathwaysExe" Name="Pathways.exe" DiskId="1" Source="\\Fileserver\Release\Pathways\Latest\Release\Pathways.exe" Vital="yes" KeyPath="yes" Assembly=".net" AssemblyApplication="pathwaysExe" AssemblyManifest="pathwaysExe">
<!--<netfx:NativeImage Id="ngen_Pathways.exe" Platform="32bit" Priority="2"/> -->
</File>
<File Id="pathwaysChm" Name="Pathways.chm" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Pathways.chm" />
<File Id="publicKeyXml" ShortName="RSAPUBLI.XML" Name="RSAPublicKey.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\RSAPublicKey.xml" Vital="yes" />
<File Id="staticListsXml" ShortName="STATICLI.XML" Name="StaticLists.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\StaticLists.xml" Vital="yes" />
<File Id="axInteropMapPointDll" ShortName="AXMPOINT.DLL" Name="AxInterop.MapPoint.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\AxInterop.MapPoint.dll" Vital="yes" />
<File Id="interopMapPointDll" ShortName="INMPOINT.DLL" Name="Interop.MapPoint.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Interop.MapPoint.dll" Vital="yes" />
<File Id="mapPointDll" ShortName="MAPPOINT.DLL" Name="MapPoint.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Interop.MapPoint.dll" Vital="yes" />
<File Id="devExpressData63Dll" ShortName="DAAT63.DLL" Name="DevExpress.Data.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.Data.v6.3.dll" Vital="yes" />
<File Id="devExpressUtils63Dll" ShortName="UTILS63.DLL" Name="DevExpress.Utils.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.Utils.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraBars63Dll" ShortName="BARS63.DLL" Name="DevExpress.XtraBars.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraBars.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraNavBar63Dll" ShortName="NAVBAR63.DLL" Name="DevExpress.XtraNavBar.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraNavBar.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraCharts63Dll" ShortName="CHARTS63.DLL" Name="DevExpress.XtraCharts.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraCharts.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraEditors63Dll" ShortName="EDITOR63.DLL" Name="DevExpress.XtraEditors.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraEditors.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraPrinting63Dll" ShortName="PRINT63.DLL" Name="DevExpress.XtraPrinting.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraPrinting.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraReports63Dll" ShortName="REPORT63.DLL" Name="DevExpress.XtraReports.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraReports.v6.3.dll" Vital="yes" />
<File Id="devExpressXtraRichTextEdit63Dll" ShortName="RICHTE63.DLL" Name="DevExpress.XtraRichTextEdit.v6.3.dll" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\DevExpress.XtraRichTextEdit.v6.3.dll" Vital="yes" />
<RegistryValue Id="PathwaysInstallDir" Root="HKLM" Key="Software\Tribal Data Resources\Pathways" Name="InstallDir" Action="write" Type="string" Value="[INSTALLDIR]" />
</Component>
</DirectoryRef>
<!-- application data components -->
<DirectoryRef Id="CommonAppDataPathways">
<Component Id="CommonAppDataPathwaysFolderComponent" Guid="087C6F14-E87E-4B57-A7FA-C03FC8488E0D">
<CreateFolder>
<Permission User="Everyone" GenericAll="yes" />
</CreateFolder>
<RemoveFolder Id="CommonAppDataPathways" On="uninstall" />
<!-- <RegistryValue Root="HKCU" Key="Software\TDR\Pathways" Name="installed" Type="integer" Value="1" KeyPath="yes" />-->
</Component>
<Component Id="Settings" Guid="A3513208-4F12-4496-B609-197812B4A953" NeverOverwrite="yes">
<File Id="settingsXml" KeyPath="yes" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />
</Component>
<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" >
<!-- <RegistryValue Root="HKLM" Key="Software\TDR\Pathways\Database" Name="installed" Type="integer" Value="1" KeyPath="yes" /> -->
<File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" CompanionFile="pathwaysExe" Vital="yes"/>
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" CompanionFile="pathwaysExe" Vital="yes"/>
</Component>
<!--
<Component Id="MDF" Guid="FFB7CE02-B592-4c44-A315-99CF4828E3D9" >
<File Id="pathwaysMdf" KeyPath="yes" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" />
</Component>
<Component Id="LDF" Guid="9E4E3DCA-A067-47f4-9905-4AD5C35A8025" >
<File Id="pathwaysLdf" KeyPath="yes" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" />
</Component>
-->
</DirectoryRef>
<!-- shortcut components -->
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcutComponent" Guid="1BF412BA-9C6B-460D-80ED-8388AC66703F">
<Shortcut Id="DesktopShortcut"
Target="[INSTALLDIR]Pathways.exe"
Name="Pathways"
Description="Pathways Tribal Directory"
Icon="PathwaysIcon"
Show="normal"
WorkingDirectory="INSTALLDIR" />
<RegistryValue Root="HKCU" Key="Software\TDR\Pathways" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id ="ProgramsMenuPathwaysFolder">
<Component Id="ProgramsMenuShortcutComponent" Guid="83A18245-4C22-4CDC-94E0-B480F80A407D">
<Shortcut Id="ProgramsMenuShortcut" Target="[INSTALLDIR]Pathways.exe" Name="Pathways" Icon="PathwaysIcon" Show="normal" WorkingDirectory="INSTALLDIR" />
<RemoveFolder Id="ProgramsMenuPathwaysFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\TDR\Pathways" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id="App" Title="Pathways Application" Level="1" Description="Pathways software" Display="expand" ConfigurableDirectory="INSTALLDIR" Absent="disallow" AllowAdvertise="no" InstallDefault="local">
<ComponentRef Id="Application" />
<ComponentRef Id="CommonAppDataPathwaysFolderComponent" />
<ComponentRef Id="Settings"/>
<ComponentRef Id="ProgramsMenuShortcutComponent" />
<Feature Id="Shortcuts" Title="Desktop Shortcut" Level="1" Absent="allow" AllowAdvertise="no" InstallDefault="local">
<ComponentRef Id="DesktopShortcutComponent" />
</Feature>
</Feature>
<Feature Id="Data" Title="Database" Level="1" Absent="allow" AllowAdvertise="no" InstallDefault="local">
<ComponentRef Id="Database" />
</Feature>
<UIRef Id ="WixUI_FeatureTree"/>
<UIRef Id="WixUI_ErrorProgressText"/>
<UI>
<Error Id="2000">There is a later version of this program installed.</Error>
</UI>
<CustomAction Id="NewerVersionDetected" Error="2000" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize"/>
</InstallExecuteSequence>
</Product>
Running this installer attempting the upgrade from the previous version ALMOST WORKS. The file that is giving me trouble is the one called "PathwaysMdf". Even though it's Component code is EXACTLY the same as the PathwaysLdf file, that file is replaced, while the MDF is NOT. You can see, commented out, some of the other things I've attempted, some from suggestions on stackoverflow.
The entire log file from running the upgrade is located at:
http://pastebin.com/ppjhq6Wi
THANK YOU!
Joshua
Are you following the component rules?
Why are you not using one file per component? Multiple files in a component gets very ugly, very quickly.
(Note that this isn't really a WiX issue, but more likely to be a Windows Installer issue due to violation of component rules)
Why are you setting the CompanionFile attribute for those files to "pathwaysExe"? In doing so, you are asking Windows Installer to base the decision to update those files on whether or not "pathwaysExe" is also updated. Since the version of "pathwaysExe" has not changed (and thus Windows Installer won't updated it), the other files are likewise not updated.
By the way, you say that the .ldf file is updated...Are you sure? The log file you posted indicates otherwise.