2016-01-08 107 views
1

我正在嘗試安裝幾種我們的應用程序所共有的一些字體,因此它似乎將它們放入單個共享合併模塊中是行之有效的方法。但我無法獲得準確的Wix語法。這裏是我在我的合併模塊配置文件中有:如何在Wix合併模塊中安裝字體

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Module Id="TS3DFontsMerge" Language="1033" Version="1.0.0.0"> 
    <Package Id="F6029400-FD05-4213-A0B2-1755387595BF" Manufacturer="Tech Soft 3D" InstallerVersion="200" /> 
    <DirectoryRef Id="FontsFolder"> 
      <Component Id="TechSoft3DFonts" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5"> 
       <File Id="ts3d.ttf" Source="..\..\..\samples\fonts\ts3d.ttf" TrueType="yes" /> 
       <File Id="MyriadCAD.otf" Source="..\..\..\samples\fonts\MyriadCAD.otf" TrueType="yes" /> 
     </Component> 
    </DirectoryRef> 
    </Module> 
</Wix> 

我遵循模型here。在這種情況下,我得到這個錯誤:

ts3d_fonts_merge.wxs(5,0): error CNDL0205: The Directory with Id 'FontsFolder' is not a valid root directory. There may only be a single root directory per product or module and its Id attribute value must be 'TARGETDIR' and its Name attribute value must be 'SourceDir'. ts3d_fonts_merge.wxs(5,0): error CNDL0025: The Directory element requires the Name attribute because there is no parent Directory element.

所以我獲取到了點問題是:我怎樣才能得到維克斯認識到合併模塊中的FontsFolder預定義的ID?我正在使用WixToolset v3.10。

這裏有幾個其他的事情我想...

當我有這個直接在主產品安裝程序,我不得不使用<目錄>標籤,而不是<DirectoryRef>,那工作。但是當我使用該合併模塊中,我得到這個錯誤信息:

ts3d_fonts_merge.wxs(5,0): error LGHT0094: Unresolved reference to symbol 'Directory:FontsFolder' in section 'Module:TS3DFontsMerge'.

如果我在TARGETDIR標籤包裹FontsFolder,我得到警告,字體(如由第一個錯誤建議?)正在安裝到錯誤的地方。這裏是錯誤信息:

light.exe(0,0): warning LGHT1076: ICE07: 'ts3d.ttf.F6029400_FD05_4213_A0B2_1755387595BF' is a Font and must be installed to the FontsFolder. Current Install Directory: 'FontsFolder.F6029400_FD05_4213_A0B2_1755387595BF' light.exe(0,0): warning LGHT1076: ICE07: 'MyriadCAD.otf.F6029400_FD05_4213_A0B2_1755387595BF' is a Font and must be installed to the FontsFolder. Current Install Directory: 'FontsFolder.F6029400_FD05_4213_A0B2_1755387595BF'

任何想法?

回答

2

一對夫婦的簡單建議:

所以在最後,你應該接近:

?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Module Id="TS3DFontsMerge" Language="1033" Version="1.0.0.0"> 
    <Package Id="F6029400-FD05-4213-A0B2-1755387595BF" Manufacturer="Tech Soft 3D" InstallerVersion="200" /> 
    <Directory Id="TARGETDIR"> 
     <Directory Id="FontsFolder"> 
      <Component Id="TechSoft3DFonts" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5"> 
       <File Id="ts3d.ttf" Source="..\..\..\samples\fonts\ts3d.ttf" TrueType="yes" /> 
       </Component> 
       <Component Id="TechSoft3DFonts2" Guid="0B9C43FC-3735-42DE-80F6-1DB2A912BEE5"> 
       <File Id="MyriadCAD.otf" Source="..\..\..\samples\fonts\MyriadCAD.otf" TrueType="yes" /> 
     </Component> 
     </Directory> 
    </Directory> 
    </Module> 
</Wix> 
1

我有同樣的問題,但我沒有從以前的答案的整體解決方案。

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

    <Product (...)> 
    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="FontsFolder" /> 
    </Directory> 

    <DirectoryRef Id="FontsFolder"> 
     <Component Id="MyFont" Guid="0B9C43FC-3735-42DE-80F6-1DB2A912BEE5"> 
     <File Id="MyFont.otf" Source="Fonts\MyFont.otf" TrueType="yes" /> 
     </Component> 
     <Component Id="MySecondFont" Guid="0B9C43FC-3835-42DE-80F6-1DB2A912BEE5"> 
      <File Id="MySecondFont.otf" Source="Fonts\MySecondFont.otf" TrueType="yes" /> 
     </Component> 
    </DirectoryRef> 

    <Feature Id="FontsInstallation" Title="Install and Register Company Fonts" Level="1"> 
     <ComponentRef Id="MyFont"/> 
     <ComponentRef Id="MySecondFont"/> 
    </Feature> 
    </Product> 
</Wix> 

的字體不是畫圖或Word可見的,但我可以用原來的名稱使用XAML/WPF代碼中引用(因爲它們將被安裝在Windows中):

<TextBlock FontFamily="My First Font" FontSize="30">Sample text</TextBlock> 
<TextBlock FontFamily="My Second Font" FontSize="30">Sample text</TextBlock> 

字體文件設置爲構建動作內容複製到輸出目錄DoNotCopy

+1

上一個答案和問題是關於模塊,這些模塊是安裝程序的一部分。使用模塊允許任何人將相同的部分添加到不同的安裝程序,並獲得相同的GUID和結果。您上面的代碼確實可以將字體放入字體文件夾,但它是創建單個安裝程序的產品,無法與其他安裝共享。儘管您的解決方案確實顯示瞭如何正確使用DirectoryRef以用於安裝程序並正確解決單個安裝問題。做得很好! – ProjectNapalm