2014-12-02 37 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"; 

它的工作原理。始終參考裝配。

相關問題