Wpf 为具有多个项目的解决方案创建Wix安装程序

Wpf 为具有多个项目的解决方案创建Wix安装程序,wpf,visual-studio-2012,wix,Wpf,Visual Studio 2012,Wix,我有一个Wpf解决方案,它由两个项目组成,一个是windows应用程序,另一个是类库。当我尝试创建安装程序时,它工作正常,但当我运行应用程序时,它崩溃了。 当我把所有的代码放在一个项目中时,一切都很好 那么,当有多个项目时,我如何使其工作 我的Product.wxs是: <Product Id="8748CF04-E8D3-4A2B-B3F5-22E50B3A8E49" Name="MyApp" Language="1033" Version="1.0.0.0" Manufa

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

那么,当有多个项目时,我如何使其工作

我的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>

我遵循了本教程:

好吧,我终于自己弄明白了

<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。

是否在安装程序中包含类库(以便也安装它)?