2016-10-11 131 views
0

我有一個WiX安裝程序和自定義操作項目。我添加了C#庫作爲自定義操作項目的參考。這C#dll使用DllImport到一個C++ dll。安裝時收到錯誤:無法加載DLL mycpp.dll:未找到指定的模塊。我將mycpp.dll添加到CA項目,並嘗試使用屬性:嵌入式資源,複製到輸出目錄 - 但沒有結果。我怎樣才能讓我的安裝程序找到mycpp.dllWIX自定義操作:使用dllimport

回答

1

我以前有過這個問題。在閱讀完MSBuild文件的wix後,我最終找到了一個屬性,該屬性用作包含自定義動作dll的自解壓縮包中所需的dll的列表。

在wix.ca.targets(在sdk文件夾中)有一個名爲CustomActionContents的屬性,用於運行makesfxca時使用。

下面是包含您的自定義操作DLL的這套msbuild目標的註釋。

<!-- 
================================================================================================== 
PackCustomAction 

Creates an MSI managed custom action package that includes the custom action assembly, 
local assembly dependencies, and project content files. 

[IN] 
@(IntermediateAssembly) - Managed custom action assembly. 
@(Content) - Project items of type Content will be included in the package. 
$(CustomActionContents) - Optional space-delimited list of additional files to include. 

[OUT] 
$(IntermediateOutputPath)$(TargetCAFileName) - Managed custom action package with unmanaged stub. 
================================================================================================== 
--> 

<!-- 
Items to include in the CA package: 
- Reference assemblies marked CopyLocal 
- Project items of type Content 
- Additional items in the CustomActionContents property 
--> 

所以看起來你可以標記您參考mycpp.dll複印地方,它會自動拾取,也可以在您的自定義操作添加新的屬性項目(可能編輯csproj並添加屬性),其中包含dll的路徑,它會被拾取。