2014-12-02 36 views
0

我不知道标题是否真的正确(欢迎任何更正)。启动关联文件“wix”时不从InstallDir开始进程

我创建了一个wpf应用程序,并使用Wix生成安装程序。此应用程序可以创建一个项目并将其保存在任何目录中。

我想做的事,就是能够启动我的应用程序,并打开该项目,通过只是做就可以了双击(如点击为Visual Studio的.sln文件)

做,我在product.wxs添加以下代码:

<Directory Id="GlobalFolder" Name="$(var.CompanyName)" > 
     <Directory Id="APPLICATIONFOLDER" Name="$(var.ProductName)"> 
     <Directory Id="ProtocolsFOLDER" Name="ProtocolFiles"/> 
     <Directory Id="ImagesFOLDER" Name="Images"/> 
     <Component Id="MainExecutable" Guid="3948E0F1-BF20-4620-81D8-EE5867C4F96F"> 
      <File Id="exe" Name="ARROW.exe" DiskId="1" 
      Source="$(var.Arrow.TargetDir)\Arrow.exe" KeyPath="yes"> 
      </File> 
      <!-- Capabilities keys for Vista/7 "Set Program Access and Defaults" --> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities" Name="ApplicationDescription" Value="Arrow Application" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities" Name="ApplicationIcon" Value="[APPLICATIONFOLDER]ARROW.exe,0" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities" Name="ApplicationName" Value="ARROW" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities\DefaultIcon" Value="[APPLICATIONFOLDER]ARROW.exe,1" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities\FileAssociations" Name=".arr" Value="Arrow.Document" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities\MIMEAssociations" Name="application/Arrow" Value="Arrow.Document" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\Capabilities\shell\Open\command" Value="&quot;[APPLICATIONFOLDER]Arrow.exe&quot; -c &quot;%1&quot;" Type="string" /> 
      <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)\RegisteredApplications" Name="Arrow" Value="Software\$(var.ProductName)\Capabilities" Type="string" /> 

      <!-- App Paths to support Start,Run -> "ARROW" --> 
      <RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Arrow.exe" Value="Arrow.exe" Type="string" /> 
      <RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Arrow.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" /> 

      <!-- Extend to the "open with" list + Win7 jump menu pinning --> 
      <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\Arrow.exe\SupportedTypes" Name=".arr" Value="" Type="string" /> 
      <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\Arrow.exe\shell\open" Name="Arrow Software" Value="Arrow" Type="string" /> 
      <!-- MyApp.Document ProgID --> 
      <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Arrow.Document" Name="arr" Value="Arrow Project File" Type="string" /> 
      <ProgId Id="Arrow.Document" Description="Arrow Project File" > 
      <Extension Id="arr"> 
       <Verb Id="open" Command="Open Arrow" Target="exe" TargetFile="exe" Argument=" &quot;%1&quot;" /> 
       <MIME ContentType="application/ARROW" Default="yes" /> 
      </Extension> 
      </ProgId> 
     </Component> 
     </Directory> 
    </Directory> 

它工作得很好,当我在它打开我的应用程序的项目双击,但问题是,应用程序从该目录需要一些文件(安装文件夹)

<Directory Id="ProtocolsFOLDER" Name="ProtocolFiles"/> 

但是,当我使用Visual附加进程时,发现应用程序在项目位置(双击它的项目)中搜索需要的文件。

它看起来像在registryValues某处的索引问题!谁能帮我?谢谢

回答

0

最后,所有这些行为都是正常的。我所要做的是改变我的相对路径我的应用程序源代码,从里面像:

@(Directory\FileName) 

要:

Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Directory\FileName"; 

它的工作原理。始终参考装配。

相关问题