2015-11-03 76 views
0

我有一个由2个项目组成的Wpf解决方案,其中一个是Windows应用程序,另一个是类库。当我尝试创建安装程序时,它工作正常,但是当我运行应用程序时,它崩溃了。 当我把所有的代码放在一个项目中时,它都可以正常工作。为多个项目创建一个Wix安装程序

那么,如何在有多个项目时使其工作?

我Product.wxs是:

<Product Id="8748CF04-E8D3-4A2B-B3F5-22E50B3A8E49" 
     Name="MyApp" Language="1033" Version="1.0.0.0" Manufacturer="My System Pvt Ltd" 
     UpgradeCode="8748CF04-E8D3-4A2B-B3F5-22E50B3A8E49"> 

<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" 
      InstallPrivileges="elevated" ReadOnly="yes"/> 

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
<!--Add Cab1.cab File inside the Package--> 
<Media Id="1" Cabinet="cab1.cab" EmbedCab="yes" /> 

<!--Here We Install Our Main App--> 
<Directory Id="TARGETDIR" Name="SourceDir"> 
    <Directory Id="ProgramFilesFolder"> 
    <Directory Id="INSTALLFOLDER" Name="MY System Pvt Ltd"/> 
    </Directory> 

    <!-- Step 1: For the Program Menu --> 
    <Directory Id="ProgramMenuFolder"> 
    <Directory Id="ApplicationProgramsFolder" Name="My System Pvt Ltd"/> 
    </Directory> 

    <!--Step 2:For Desktop Folder--> 
    <Directory Id="DesktopFolder"/> 

    <!--Step 3:For StartUp Folder--> 
    <Directory Id="StartupFolder"/> 

</Directory> 

<!--Step 4 :Add Main App exe--> 
<DirectoryRef Id="INSTALLFOLDER"> 
    <Component Id="myapplication.exe" Guid="84C5B9E8-FD90-4EA8-A502-B08AC9B38D39"> 
    <File Source="C:\Users\petric\Downloads\Compressed\WixDemoWPFAppVS2012\WixDemoWPFAppVS2012\WixDemoWPFAppVS2012\WpfApplication2\bin\Debug\WpfApplication2.exe" Name="MYApp.exe" 
      Id="MyAppEXE" KeyPath="yes"/> 
    </Component> 
</DirectoryRef> 

<!-- Step 1.1: Add the shortcut to your installer package Program Menu or Start Menu--> 
<DirectoryRef Id="ApplicationProgramsFolder"> 
    <Component Id="ApplicationShortcut" Guid="1A437020-D5C9-450C-9B3D-33957994780A"> 
    <!--Add Shortcut of the Application in start Menu--> 
    <Shortcut Id="ApplicationStartMenuShortcut" Name="MyApp" Description="My Application Description" 
     Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER"> 
     <!--Add Icon to the ShortCut--> 
     <Icon Id="MYPMenuIcon" SourceFile=".\Desktop.ico" /> 
    </Shortcut> 
    <!--Remove the Folder At time of Uninstall--> 
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/> 
    <RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]' 
        Name="installed" Type="integer" Value="1" KeyPath="yes"/> 
    </Component> 
</DirectoryRef> 

<!-- Step 2.1: Add the shortcut to your installer package For DeskTop--> 
<DirectoryRef Id="DesktopFolder"> 
    <Component Id="ApplicationDeskShortcutComp" Guid="40127963-856D-460D-9E1B-4C10EB65835B"> 
    <Shortcut Id="ApplicationDeskShortcut" Name="MYAppDesk" 
       Description="My Application Description" Target="[INSTALLFOLDER]MyApp.exe" 
       WorkingDirectory="INSTALLFOLDER"> 
     <Icon Id="MYDeskIcon" SourceFile=".\Desktop.ico" /> 
    </Shortcut> 
    <RemoveFolder Id="DesktopFolder" On="uninstall"/> 
    <RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]' 
        Name="installed" Type="integer" Value="1" KeyPath="yes"/> 
    </Component> 
</DirectoryRef> 

<!--Step 3.1: add Shortcut to StartUp Folder to run application when you login--> 
<DirectoryRef Id="StartupFolder"> 
    <Component Id="ApplicationStartUpShortcutComp" Guid="843B6A2E-AB61-40C7-BE49-FBCD7F81E35D"> 
    <Shortcut Id="ApplicationStartUpDeskShortcut" Name="MYAppDesk" Description="My Application Description" 
     Target="[INSTALLFOLDER]MyApp.exe" WorkingDirectory="INSTALLFOLDER"> 
     <Icon Id="MyIconStartUp" SourceFile=".\Desktop.ico" /> 
    </Shortcut> 
    <RemoveFolder Id="StartupFolder" On="uninstall"/> 
    <RegistryValue Root="HKCU" Key='Software\[Manufacturer]\[ProductName]' 
        Name="installed" Type="integer" Value="1" KeyPath="yes"/> 
    </Component> 
</DirectoryRef> 

<!--Add Component--> 
<Feature Id="MainApplication" Title="Main Application" Level="1"> 
    <ComponentRef Id="myapplication.exe" /> 
    <!--Step 1.2:Add Start menu or program Shortcut--> 
    <ComponentRef Id="ApplicationShortcut" /> 
    <!--step 2.2Add DeskTop Shortcut--> 
    <ComponentRef Id="ApplicationDeskShortcutComp" /> 
    <!--step 3.2Add DeskTop Shortcut--> 
    <ComponentRef Id="ApplicationStartUpShortcutComp"/> 
</Feature> 

我跟着这个教程: http://www.c-sharpcorner.com/UploadFile/cb88b2/getting-started-with-wix-windows-installer-xml-in-vs2012/

+0

您是否将类库包含在安装程序中(以便它也已安装)? – Nikolay

+0

看到我的答案.. – petric

回答

1

好吧,我想通了自己最终

<DirectoryRef Id="INSTALLFOLDER"> 
<Component Id="myapplication.exe" Guid="84C5B9E8-FD90-4EA8-A502-B08AC9B38D39"> 
<File Source="C:\Users\petric\Downloads\Compressed\WixDemoWPFAppVS2012\WixDemoWPFAppVS2012\WixDemoWPFAppVS2012\WpfApplication2\bin\Debug\WpfApplication2.exe" Name="MYApp.exe" 
     Id="MyAppEXE" KeyPath="yes"/> 
</Component> 
</DirectoryRef> 

应该被当作使用:

<DirectoryRef Id="INSTALLFOLDER"> 
    <Component Id="myapplication.exe" Guid="84C5B9E8-FD90-4EA8-A502-B08AC9B38D39"> 
    <File Source="$(var.WpfApplication2.TargetPath)" Name="MYApp.exe" 
      Id="MyAppEXE" KeyPath="yes"/> 
    </Component> 
    <Component> 
    <File Id="dotNetClass.Output" 
      Name="WpfApplication3.dll" 
      Source="$(var.WpfApplication3.TargetPath)" 
      KeyPath="yes" /> 
    </Component> 
</DirectoryRef> 

包含一个名为WpfApplication3的项目的dll。

相关问题