2011-11-07 32 views
10

Tôi đang cố gắng tạo trình cài đặt WiX cho dịch vụ cửa sổ và tôi đã đọc rằng tôi đã đặt keyPath thành "không" cho tất cả các tệp của mình, với ngoại trừ .exe trong tập lệnh WiX của tôi. Tôi hiện đang tạo Directory và tập tin cấu trúc của tôi sử dụng Heat.exe đây là lệnh của tôi:Trình cài đặt WiX: sử dụng xslt với heat.exe để cập nhật các thuộc tính

"$(WIX)bin\heat.exe" dir $(SolutionDir)EmailGenerationService\bin\PROD 
        -cg EmailGenFiles -gg -scom -sreg -sfrag -srd -suid 
        -dr INSTALLLOCATION -var var.FileSource 
        -t $(Projectdir)KeyPathTransform.xslt 
        -out $(ProjectDir)DirectoryAndFileComponents.wxs 

Đó là ý định của tôi để cập nhật tất cả các yếu tố tập tin với Keypath =”no” trong tập tin DirectoryAndFileComponents.wxs tôi. Một ví dụ về sản lượng từ nhiệt là:

<?xml version="1.0" encoding="utf-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 
    <DirectoryRef Id="INSTALLLOCATION"> 
     <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}"> 
     <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" /> 
     </Component> 
     <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}"> 
     <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" /> 
     </Component> 
     <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}"> 
     <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" /> 
     </Component> 
     <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}"> 
     <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" /> 
     </Component> 

Đây là XSLT tôi đi qua để làm nóng để thực hiện việc chuyển đổi:

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
      exclude-result-prefixes="msxsl" 
      xmlns:wix="http://schemas.microsoft.com/wix/2006/wix" 
      xmlns:my="my:my"> 

    <xsl:output method="xml" indent="no"/> 

    <xsl:strip-space elements="*"/> 

    <xsl:template match="@*|node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
    </xsl:template> 

    <xsl:template match='/wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id="EmailGenerationService.exe")]'> 
    <xsl:attribute name="KeyPath"> 
      <xsl:value-of select="no"/> 
    </xsl:attribute> 
    </xsl:template> 
</xsl:stylesheet> 

Tôi đã thử khá một vài biến thể của việc này dựa trên khác các bài đăng trên trang này và những nơi khác, nhưng vẫn chưa thể nhận được tệp được tạo bởi heat.exe để có KeyPath = "không".

Tôi có thiếu thứ gì đó hiển nhiên không?

Trả lời

11

Bạn có không gian tên khác nhau được xác định:

  1. Trong XML: _ http://schemas.microsoft.com/wix/2006/wi
  2. Trong XSLT: http://schemas.microsoft.com/wix/2006/wix

Như tôi biết, đúng không gian tên cho WiX là http://schemas.microsoft.com/wix/2006/wi. Vì vậy, bạn nên sửa XSLT của mình.

XSLT:

<xsl:stylesheet version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
      exclude-result-prefixes="msxsl" 
      xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" 
      xmlns:my="my:my"> 

    <xsl:output method="xml" indent="yes" /> 

    <xsl:strip-space elements="*"/> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match='wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id = "EmailGenerationService.exe")]'> 
     <xsl:copy> 
      <xsl:apply-templates select="@*"/> 
      <xsl:attribute name="KeyPath"> 
       <xsl:text>no</xsl:text> 
      </xsl:attribute> 
     </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 

Input XML:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 
     <DirectoryRef Id="INSTALLLOCATION"> 
      <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}"> 
       <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" /> 
      </Component> 
      <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}"> 
       <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" /> 
      </Component> 
      <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}"> 
       <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" /> 
      </Component> 
      <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}"> 
       <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" /> 
      </Component> 
     </DirectoryRef> 
    </Fragment> 
</Wix> 

Output XML:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 
    <DirectoryRef Id="INSTALLLOCATION"> 
     <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}"> 
     <File Id="Dollar.Common.dll" Source="$(var.FileSource)\Dollar.Common.dll" KeyPath="no" /> 
     </Component> 
     <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}"> 
     <File Id="Dollar.Common.Exceptions.dll" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" KeyPath="no" /> 
     </Component> 
     <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}"> 
     <File Id="Dollar.Common.Exceptions.pdb" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" KeyPath="no" /> 
     </Component> 
     <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}"> 
     <File Id="Dollar.Common.Logging.dll" Source="$(var.FileSource)\Dollar.Common.Logging.dll" KeyPath="no" /> 
     </Component> 
    </DirectoryRef> 
    </Fragment> 
</Wix> 
+0

Cảm ơn bạn đã phản hồi, nhưng điều này cũng không hoạt động. Nhiệt chạy ok với lỗi ra, nhưng tập tin kết quả vẫn có KeyPath = "có" trên tất cả các nút. –

+0

@MarkJones, tôi đã cập nhật câu trả lời của mình. –

+1

hoàn hảo, cảm ơn bạn rất nhiều –

2

tôi sẽ không trả lời câu hỏi ban đầu của bạn. :)

Tôi đã đọc mà tôi nned để thiết lập keyPath để “không” cho tất cả các tác phẩm của tôi, với ngoại lệ của .exe

Tôi nghĩ rằng bạn đã hiểu sai lệch. Trong thực tế ServiceInstall table có một cột Component_, và theo MSDN:

để cài đặt dịch vụ này bằng cách sử dụng bảng InstallService, các KeyPath cho thành phần này phải là tập tin thực thi cho dịch vụ.

Điều đó không có nghĩa là các tệp không phải trong các thành phần khác phải có @KeyPath='no'. Nó chỉ nói rằng tệp EXE của dịch vụ phải nằm trong một thành phần riêng biệt và phải là đường dẫn chính của nó.

Con đường chính là một khái niệm rất quan trọng của công nghệ MSI. Bạn có thể đọc thêm về nó here, see the description of the KeyPath column.

Bây giờ, nếu chúng ta quay lại câu hỏi ban đầu của bạn - không, bạn không phải tinh chỉnh đầu ra nhiệt theo cách bạn đã đề cập. Nó sẽ tạo ra các tác giả WiX bạn cần theo mặc định.

+0

Cảm ơn thông tin Yan, tôi lấy các giả định của tôi từ đây: http://blog.tentaclesoftware.com/archive/2009/01/01/21.aspx –

+0

Trong ví dụ mẫu bạn tham khảo một thành phần có chứa một số tệp. Đúng là chỉ có một tệp có thể được đánh dấu là KeyPath = 'yes', nhưng bạn không phải đánh dấu rõ ràng những người khác là KeyPath = 'no'. Và trong mẫu heat.exe được tạo ra cho bạn, giả định của bạn hoàn toàn sai. –

+0

@Mark Jones, xin lỗi nếu nhận xét trước của tôi có vẻ như được thể hiện dưới dạng khó khăn. Tôi chỉ đơn giản là không thể cưỡng lại phản ứng khi tôi thấy mọi người dành thời gian và nỗ lực cố gắng giải quyết một vấn đề không tồn tại :) –

1

Tôi có thể đề xuất một cách tiếp cận khác không?

<xsl:template match="@KeyPath[parent::wix:File[parent::wix:Component[parent::wix:DirectoryRef[parent::wix:Fragment[parent::wix:Wix]]]] and . != 'EmailGenerationService.exe']"> 
     <xsl:attribute name="KeyPath"> 
      <xsl:value-of select="'no'"/> 
     </xsl:attribute> 
</xsl:template> 

Chỉ cần thay đổi mẫu của bạn khớp với ở trên và bạn sẽ có kết quả chính xác.

Các vấn đề liên quan