Can anybody help me find out why my Windows service won't start.
When I install it with installutil, it works perfectly. I decided to use wix to create an installer for the end user but it won't start.
Here's my code
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IWErpnextPoll" Manufacturer="IWW" Language="1033" Version="1.0.0.0" UpgradeCode="ccc3c2fe-d20f-45ce-b978-4dc7c84ce6c8">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="IWERPNextPoll_Setup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="IWErpnextPoll" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Source="$(var.IWErpnextPoll.TargetPath)" />
<ServiceInstall Id="ServiceInstaller" Name="IWErpnextPoll" Type="ownProcess" Vital="yes" DisplayName="ERPNext2Sage" Description="A background service." Start="auto" Account=".\LocalSystem" ErrorControl="normal" Interactive="no" />
<ServiceControl Id="StartService" Name="IWErpnextPoll" Stop="both" Start="install" Remove="uninstall" Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
The installer throws this error:
Service 'IWErpnextPoll' (IWErpnextPoll) failed to start. Verify that you have sufficient privileges to start system services
I ran the following in the command line:
msiexec /i IWERPNextPoll_Setup /l*v log.txt
but (my untrained eyes) didn't find anything that seemed off in the very very log file.
The service I wrote is my first forray into C#. I'll be very happy to get any pointers.
99.99% of the time this is a problem with the service.
A couple of pro tips.
1) Don't author the ServiceControl element for the first few builds until you know the thing is solid. Test the service after installation.
2) If you do author it, let it sit on the failed to start dialog and start profiling. Run the EXE from a command prompt and see if it is missing dependencies or throws errors. Have lots of logging code in the service to understand what is wrong.
ServiceInstaller is a form of self registration anti pattern. Perhaps you had some code in there doing something like creating an EventSource or a registry key and without it your service is throwing an exception.
Only profiling/debugging will tell for sure.
The answer by #Christopher Painter and the comments on my question led me towards the problem.
The problem was that I did not include my project dependencies in product.wsx. I had to add like so...
...
<Component Id="Serilog.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.dll" />
</Component>
<Component Id="Serilog.Settings.AppSettings.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.Settings.AppSettings.dll" />
</Component>
<Component Id="Serilog.Sinks.File.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.Sinks.File.dll" />
</Component>
<Component Id="RestSharp.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)RestSharp.dll" />
</Component>
...
After this, things started working as expected
Related
I'm using SQLite Database and create installer of WPF application with WIX Toolset. The problem is, The below relative path works fine when I directly run from Visual Studio but does not work when I create installer with WIX and after install this installer run program then it gives fatal error for Database file.
In Project directory I've made a Database folder, in which the database files reside as you can see in below picture:
After creating installer by WIX Toolset, installed files as below:
inventory_control.db file path:
dbConnectionString path:
I've writen code for relative path connection string as under:
Relative Path:
string relativePath = #"Database\inventory_control.db";
string currentPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
//string path = currentPath.Substring(0, currentPath.Length - 21);
string path = Path.GetDirectoryName(currentPath);
string absolutePath = System.IO.Path.Combine(path, relativePath);
string dbConnectionString = string.Format("Data Source={0};Version=3;Pooling=True;Max Pool Size=100;", absolutePath);
//string dbConnectionString = "Data Source=inventory_control.db";
sQLiteConnection = new SQLiteConnection(dbConnectionString);
dbConnectionString gives correct current path.
The above relative path works fine when I directly run from Visual Studio but does not work when I create installer with WIX. It gives a fatal error. How to resolve?
WIX File:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><?define Inventory Control_TargetDir=$(var.Inventory Control.TargetDir)?>
<Product Id="f941ba49-4369-44d4-aa0c-b77f20aa41db" Name="Inventory Control" Language="1033" Version="1.0.0.0" Manufacturer="devtros.com" UpgradeCode="ce092371-53cc-4be9-ab5d-c7a2685af970">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Icon Id="app_icon.ico" SourceFile="$(var.ProjectDir)app_icon.ico" />
<Property Id="ARPPRODUCTION" Value="app_icon.ico" />
<WixVariable Id="WixUIBannerBmp" Value="Images\background.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="Images\background.bmp" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)License.rtf" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="Inventory Control" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentGroupRef Id="Database_files" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Inventory Control">
<Directory Id="Files" Name="Files" />
<Directory Id="Database" Name="Database" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Inventory Control" />
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="9bd13330-6540-406f-a3a8-d7f7c69ae7f9">
<Shortcut Id="ApplicationStartMenuShortcut" Name="Inventory Control" Description="Inventory Control" Target="[INSTALLFOLDER]Inventory Control.exe" WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Inventory Control" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a">
<Shortcut Id="ApplicationDesktopShortcut" Name="Inventory Control" Description="Inventory Control" Target="[INSTALLFOLDER]Inventory Control.exe" WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Inventory Control" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<Component Id="Inventory_Control.exe" Guid="0a7e7061-201b-4d49-adeb-4449e9c4da3e">
<File Id="Inventory_Control.exe" Name="Inventory Control.exe" Source="$(var.Inventory Control_TargetDir)Inventory Control.exe" />
</Component>
<Component Id="Inventory_Control.exe.config" Guid="28323615-8159-4116-b1ac-e29a70bf2593">
<File Id="Inventory_Control.exe.config" Name="Inventory Control.exe.config" Source="$(var.Inventory Control_TargetDir)Inventory Control.exe.config" />
</Component>
<Component Id="System.Windows.Controls.Input.Toolkit.dll" Guid="7d678201-767a-416b-b645-b2cb7d514893">
<File Id="System.Windows.Controls.Input.Toolkit.dll" Name="System.Windows.Controls.Input.Toolkit.dll" Source="$(var.Inventory Control_TargetDir)System.Windows.Controls.Input.Toolkit.dll" />
</Component>
<Component Id="System.Data.SQLite.dll" Guid="178a5aef-c027-4215-81ae-f148ab6cd472">
<File Id="System.Data.SQLite.dll" Name="System.Data.SQLite.dll" Source="$(var.Inventory Control_TargetDir)System.Data.SQLite.dll" />
</Component>
<Component Id="Zen.Barcode.Core.dll" Guid="20e34fc3-0066-4ffd-b401-518bc1177098">
<File Id="Zen.Barcode.Core.dll" Name="Zen.Barcode.Core.dll" Source="$(var.Inventory Control_TargetDir)Zen.Barcode.Core.dll" />
</Component>
<Component Id="WPFToolkit.dll" Guid="8d974e65-defb-4675-b9e0-ff617e5ab1da">
<File Id="WPFToolkit.dll" Name="WPFToolkit.dll" Source="$(var.Inventory Control_TargetDir)WPFToolkit.dll" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="Database_files" Directory="Database">
<Component Id="Database_inventory_control.db" Guid="0104b919-0aa9-4dc5-9492-14c474d97cf1">
<File Id="Database_inventory_control.db" Name="inventory_control.db" Source="$(var.Inventory Control_TargetDir)Database\inventory_control.db" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
SQLite.Interop.dll: The file SQLite.Interop.dll needed to be installed along with the rest of the runtime files in order for SQLite
to function properly.
There are two flavors of the file, x86 and x64 format. It is
probably advisable to install both files in their respective folders:
Your installation folder hierarchy - mock-up:
YourBinary.exe
x86\SQLite.Interop.dll
x64\SQLite.Interop.dll
System.Data.SQLite.dll
Etc...
Read-Write DB Location: And then your database should be stored in a writeable path (or you need to make the path writeable for regular users using custom ACL permissioning - which is never a great idea).
Exceptions: Obviously try - catch your database connection, update and access code to detect these kinds of issues.
Folder Confusion: Is there a database file inside the Database folder? It sort of looks like the inventory_control.db file is installed to the main application folder, and not that Database sub-folder?
Maybe that file has been generated by the application.exe in the wrong folder?
Or maybe you have duplicated the file in the main folder for testing purposes?
Hard-Coded Dev-Box Sins?: What does it say in Inventory Control.exe.config?
Are there relevant settings in there that could override your code's values?
Could there be a hard-coded dev-box sin in there?
Path Builder: I assume you have "message boxed" the paths from the application during launch, in order to ensure that they are correct? I like to copy the path and do a Start => Run and paste the path to see that it opens. Press CTRL + C when the message box shows. Paste into Notepad. Extract the path and try it in Start => Run.
string path = currentPath.Substring(0, currentPath.Length - 21);. It is not very robust to hard code the number of characters in the file name to get the parent directory path?
Could you improve it by using Path.GetDirectoryName(currentPath)?
Or maybe even: string dir = currentPath.Substring(0,currentPath.LastIndexOf('\\'));
Attach Debugger & Debug Binaries?: Maybe you could install debug binaries and attach to them for debugging as described here: wix c# app doesn't launch after installing. Just to get a real step-through debugging session.
Path Spaces: That database connection string. Does it need quotes around its path? As in "path with spaces"? You may not have any spaces in the paths for your visual Studio project, but when installed there are spaces in the paths.
This constructs in your source does look weird, why is it necessary?:
<?define Inventory Control_TargetDir=$(var.Inventory Control.TargetDir)?>
I created a Wix setup to install a service. There is my product.wxs :
<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "MyCompagny"?>
<?define product = "My Service"?>
<?define service = "MyService"?>
<?define version = "!(bind.FileVersion.MyService.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="$(var.product)"
Language="1033"
Version="$(var.version)"
Manufacturer="$(var.compagny)"
UpgradeCode="XXXXXXX">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="MyService.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CPGNYFOLDER" Name="$(var.compagny)">
<Directory Id="INSTALLFOLDER" Name="$(var.product)" >
<Directory Id="Service_tessdata" Name="tessdata"/>
<Directory Id="Service_x64" Name="x64"/>
<Directory Id="Service_x86" Name="x86"/>
</Directory>
</Directory>
</Directory>
</Directory>
<ComponentGroup Id="InstallComponents">
<Component Id="InstallService" Guid="XXXXXXX" Directory="INSTALLFOLDER">
<File Id="MyService.exe.config"
Name="$(var.service).exe.config"
Source="$(var.MyService.TargetDir)\$(var.service).exe.config"
Vital="yes"/>
<File Id="MyService.exe"
Name="$(var.service).exe"
Source="$(var.MyService.TargetDir)\$(var.service).exe"
Vital="yes"/>
<!-- Install all dll -->
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="$(var.service)"
DisplayName="$(var.product)"
Description=""
Start="auto"
Account="LocalSystem"
ErrorControl="normal" />
<ServiceControl Id="Service_Start" Name="MyService" Start="install" Wait="no" />
<ServiceControl Id="Service_Stop" Name="MyService" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
<!-- Install all directories -->
</ComponentGroup>
<!-- Tell WiX to install the files -->
<Feature Id="ProductFeature" Title="$(var.product)" Level="1">
<ComponentGroupRef Id="InstallComponents" />
</Feature>
</Product>
</Wix>
When I try to install my service, I have error :
Service 'My Service' (MyService) failed to start. Verify that you
have sufficient privileges to start system services
I saw that this error is a generic error. So I ignored it. In my INSTALLFOLDER I have all files. Then I started services.msc and try to start my service. The error is :
Cannot start the service on local computer. Error 193:0xc1
I try to have more details, but I can't find what is the problem. How can I fix this ?
I finally found what was wrong.
In me service properties, I saw that the service path was pointing on MyService.exe.config.
I fixed the problem by adding KeyPath on .exe :
<File Id="MyService.exe"
Name="$(var.service).exe"
Source="$(var.MyService.TargetDir)\$(var.service).exe"
Vital="yes"
KeyPath="yes"/>
Hi I am using Wix to create an Installer that has to write a registry value with the path of the file that the installer copies on the user's system. The problem is that the registry entry should be written in this format
file:///C:/Program Files/....
In the Wix code project I have the INSTALLFOLDER Directory Id which points to
C:\Program Files\....
I am really struggling to convert the latter notation into former. I created a Custom Action hoping to set a property so that I can use that. Following is the code
Custom Action (separate DLL for now, can it be inlined?)
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
string origValue = session["INSTALLFOLDER"];
MessageBox.Show(origValue);
string retVal = origValue.Replace("\\", "//");
MessageBox.Show(retVal);
session["Custom_Prop"] = retVal;
return ActionResult.Success;
}
}
And the Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.2.0.0" Manufacturer="nik" UpgradeCode="4a74ff86-49a9-4011-9794-e1c18077172f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action='FooAction' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<CustomAction Id='FooAction' BinaryKey='FooBinary' DllEntry='CustomAction1' Execute='immediate'
Return='check'/>
<Binary Id='FooBinary' SourceFile='MyCustomAction.CA.dll'/>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="Custom_Prop" Value="[ProgramFilesFolder]"></Property>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<Component Id="cmp_Add_Mainfest_To_Registry" Guid="955A3A76-F010-4FCB-BCAF-B297AFD1C05B">
<RegistryKey Root="HKCU" Key="SOFTWARE\company">
<RegistryValue Name="LoadBehavior" Value="3" Type="integer" Action="write" />
<RegistryValue Name="Manifest" Value="[Custom_Prop]" Type="string" Action="write" KeyPath="yes"/>
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
However when I run this setup the value written in the registry is the literal string [ProgramFolder] and not its evaluation into either C:\ or C:/
Can someone help?
The reason why my code wasn't working was this line
<InstallExecuteSequence>
<Custom Action='FooAction' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
On changing the value of Before attribute as below made this work
<InstallExecuteSequence>
<Custom Action='FooAction' Before='CostFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
However given my needs were very simple I decided to not have a separate DLL for CustomAction and instead went ahead with a Custom Action in vbscript within the Wix Project. So now the code looks like
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.3.1.0" Manufacturer="nik" UpgradeCode="4a74ff86-49a9-4011-9794-e1c18077172f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action="VBScriptCommand" After="CostFinalize">NOT REMOVE</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<CustomAction Id="VBScriptCommand" Script="vbscript">
<![CDATA[
value = Session.Property("INSTALLFOLDER")
origPath=Session.Property("INSTALLFOLDER")
If Right(webdir, 1) = "\" Then
value = Left(value, Len(value) - 1)
End If
Session.Property("SOME_PROPERTY") = Replace(origPath,"\","//")
]]>
</CustomAction>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="Custom_Prop" Value="[ProgramFilesFolder]"></Property>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="cmp_Add_Mainfest_To_Registry" Guid="955A3A76-F010-4FCB-BCAF-B297AFD1C05B">
<RegistryKey Root="HKCU" Key="SOFTWARE\something">
<RegistryValue Name="LoadBehavior" Value="3" Type="integer" Action="write" />
<!--<RegistryValue Name="Manifest" Value="[#FILE_VstoManifest]|vstolocal" Type="string" Action="write" />-->
<RegistryValue Name="Manifest" Value="file:///[SOME_PROPERTY]" Type="string" Action="write" KeyPath="yes"/>
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Perhaps the purists won't like this but why use a Shot gun to kill a fly?
Nikhil helped me with his answer. My installs all go to subfolders so when I find an old component I need the parent folder for install, so I came here for an answer.
Combined with this get parent
I found how to get the parent folder since I have a known fixed install sub path.
<!-- Set INSTALLFOLDER from SERVERINSTALLFOLDER without the \Server\ -->
<CustomAction Id="VBScriptInstallFolderFromFoundServer" Script="vbscript">
<![CDATA[
pathvalue = Session.Property("SERVERINSTALLFOLDER")
if pathvalue <> "" Then
Session.Property("INSTALLFOLDER") = Left(pathvalue,Len(pathvalue)-Len("\Server\"))
End If
]]>
</CustomAction>
Combined with Locate Installation directory of another product
<Property Id="SERVERINSTALLFOLDER">
<!-- Id="C_SERVER_SERVERHOST.EXE" Guid="{xxx GUID OF my exe component xxx}" -->
<ComponentSearch Id="ServerComponentSearch" Type="file" Guid="{xxx GUID OF my exe component xxx}">
<DirectorySearch Id="ServerComponentDirectorySearch" Depth="0" AssignToProperty="yes" />
</ComponentSearch>
</Property>
And with Wix remember property pattern
storing the INSTALLFOLDER path in registry.
I can now update old, or install new getting the correct install path of previous install as suggestion.
Not quite the answer to the question but as I was lead here to get this, my answer will help others on the same path...
My InstallUISequence and InstallExecuteSequence :
<!-- Save INSTALLFOLDER parameter to CMDLINE_INSTALLFOLDER -->
<Custom Action='SaveCmdLineValue' Before='AppSearch' />
<!-- Set INSTALLFOLDER from SERVERINSTALLFOLDER without the \Server\ -->
<Custom Action="VBScriptInstallFolderFromFoundServer" After="AppSearch">
SERVERINSTALLFOLDER
</Custom>
<!-- Set INSTALLFOLDER from parameter CMDLINE_INSTALLFOLDER -->
<Custom Action='SetFromCmdLineValue' After='VBScriptInstallFolderFromFoundServer'>
CMDLINE_INSTALLFOLDER
</Custom>
And lastly... in Product I to refer to the Fragment I put these in:
<!-- Install to previous install path From parameter, OR from found installation OR from registry -->
<CustomActionRef Id='SaveCmdLineValue' />
<PropertyRef Id='INSTALLFOLDER'/><!-- include Fragment -->
<PropertyRef Id='SERVERINSTALLFOLDER'/><!-- include Fragment -->
<CustomActionRef Id='VBScriptInstallFolderFromFoundServer' /><!-- include Fragment -->
I am trying to create a installer for MVC4 application using Wix. I found an example that shows how to create an installer for a MVC4 Application at this link
But when I try to build the Wix Setup Project, it gives me errors like below
Error 16 Unresolved reference to symbol 'WixComponentGroup:MyWebWebComponents'
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 15
1 DemoWebsite.Setup
Error 17 Unresolved reference to symbol 'WixComponentGroup:DemoWebsiteIssConfiguration'
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 16
1 DemoWebsite.Setup`
I tried adding WixUIExtension as a reference but it doesn't work.
This is the Product.wxs. And feature node's children nodes causes this error
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}" Name="Demo website setup" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="9279b740-8419-45c4-9538-6a45f8e949c7">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="DemoWebsite.cab" EmbedCab="yes" />
<Property Id="DB_USER" Value="sa"/>
<Property Id="DB_PASSWORD" Value="sa"/>
<Property Id="DB_SERVER" Value="LOCAL"/>
<Property Id="DB_DATABASE" Value="DemoWebsite"/>
<Feature Id="ProductFeature" Title="DemoWebsite.Setup" Level="1">
<ComponentGroupRef Id="MyWebWebComponents" />
<ComponentGroupRef Id="DemoWebsiteIssConfiguration" />
</Feature>
<!-- Specify UI -->
<UIRef Id="MyUI" />
<Property Id="WIXUI_INSTALLDIR" Value="INETPUB" />
</Product>
<Fragment>
<!-- Will default to C:\ if that is the main disk-->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Will reference to C:\inetpub-->
<Directory Id="INETPUB" Name="Inetpub">
<!-- Will reference to c:\Inetpub\Demowebsite-->
<Directory Id="INSTALLFOLDER" Name="DemoWebsite">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
What am I doing wrong? I know its very specific for SO but I cannot find any solution on the web.
I am using VS 2012- Wix 4.0
The error message says it all: it expects a ComponentGroup-tag containing your components (containing e.g. files or registry keys). If you take a look at the example project that you linked in your question, the <ComponentGroupRef Id="DemoWebsiteIssConfiguration" />-element references a ComponentGroup with the name DemoWebsiteIssConfiguration. You can find this in the file DemoWebsite.Setup\IISConfiguration.wxs:
<ComponentGroup Id="DemoWebsiteIssConfiguration">
<ComponentRef Id="InstallWebsite" />
<ComponentRef Id="DemoWebsiteAppPool" />
</ComponentGroup>
It is a ComponentGroup which contains two components or, in this case, references to two components. These components are defined above the ComponentGroup-element in the same file.
Regarding the other ComponentGroupRef with the id MyWebComponents: The referenced ComponentGroup is created dynamically during the build. You can take a look at the file DemoWebsite.Setup\setup.build. This file is a MSBuild-file used to build the setup. It contains a target named Harvest that invokes heat, another tool in the WiX Toolset package. heat will parse e.g. a directory and gather all the files contained within and put them in a ComponentGroup that you can reference in your source file. I.e. you define a reference to a ComponentGroup and then you can create the content of this dynamically. This way you don't have to bother if a file is added to or removed from the project, as heat will gather them dynamically.
<Target Name="Harvest">
<!-- Harvest all content of published result -->
<Exec
Command='$(WixPath)heat dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
ContinueOnError="false"
WorkingDirectory="." />
</Target>
The name of the dynamically created ComponentGroup is defined with the parameter -cg. you can invoke heat with the parameter -? for a short description of the possible parameters.
I have 2 projects in my soliution:
1). Custom action class (CustomAction)
2). Wix setup project (TestSetup)
There is CustomAction.cs in CustomAction project:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace CustomAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
File.Create(#"c:\installed.txt");
return ActionResult.Success;
}
}
}
Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="TestSetup" Language="1033" Version="1.0.0.0" Manufacturer="SB2"
UpgradeCode="39d922d3-a3f5-4207-b905-124615dda25d">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="TestSetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action="CustomAction" Before="InstallFinalize" />
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="TestSetup" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="result.rtf">
<File Id="result.rtf" Source="result.rtf" KeyPath="yes" Checksum="yes" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction' />
<Binary Id='CustomAction.CA' SourceFile='..\CustomAction\bin\Debug\CustomAction.CA.dll' />
</Fragment>
</Wix>
Setup project buils without problems, but when I'm trying to run it I get a error message:
"There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor"
I think it's because of incorrect binary source file value.
Would you to show how to fix it?
The problem is that your CustomAction method name "CustomAction1" does not match with the "DLLEntry" value which you have mentioned (DllEntry='CustomAction'). You are missing "1" :)
<CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction' />
You should write like this:-
<CustomAction Id='CustomAction' BinaryKey='CustomAction.CA' DllEntry='CustomAction1' />
where CustomAction1 is your CustomAction Name..