Light.exe 错误 LGHT0307 'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute' 未在程序集中定义 [英] Light.exe error LGHT0307 'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute' was not defined in the assembly
问题描述
我正在使用 wix 灯和蜡烛创建批处理文件来为项目创建 msi.
I am creating a batch file using wix light and candle to create an msi for a project.
我在运行批处理文件时收到此错误:
I am receiving this error when i run the batch file:
light.exe:错误 LGHT0307:要么'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute'未在程序集中定义或在扩展中定义的类型'C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.dll'无法加载.
light.exe : error LGHT0307 : Either 'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute' was not defined in the assembly or the type defined in extension 'C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.dll' could not be loaded.
我检查了 CustomAction.dll 的文件路径并验证它是正确的.我已将 CustomAction.dll 扩展添加到 light 命令.我正在以管理员模式从 Windows 命令行运行此批处理文件.
I have checked the filepath of the CustomAction.dll and verified it is correct. I have added the CustomAction.dll extension to the light command. I am running this batch file from the windows command line in administrator mode.
批处理文件
----第1行-----
----Line 1-----
"%WIX%bin\candle" *.wxs-dCustomAction.TargetDir="C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\"-o obj\Debug\
"%WIX%bin\candle" *.wxs -dCustomAction.TargetDir="C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\" -o obj\Debug\
----第2行-----------
----Line 2----------
"%WIX%bin\light" obj\Debug*.wixobj -extC:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.dll"-ext "C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.CA.dll"-ext "C:\Program Files (x86)\WiX 工具集 v3.11\bin\WixUIExtension.dll" -ext "C:\Program Files (x86)\WiX 工具集 v3.11\bin" -ext WixIIsExtension -ext WixNetFxExtension-ext WixUIExtension -extWixUtilExtension -ext"C:\Users\User1\Documents\testProj\Utils\bin\Debug\Utils.dll" -oobj\Debug\CommandLineInstaller.msi
"%WIX%bin\light" obj\Debug*.wixobj -ext "C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.dll" -ext "C:\Users\User1\Documents\testProj\CustomAction\bin\Debug\CustomAction.CA.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" -ext WixIIsExtension -ext WixNetFxExtension -ext WixUIExtension -ext WixUtilExtension -ext "C:\Users\User1\Documents\testProj\Utils\bin\Debug\Utils.dll" -o obj\Debug\CommandLineInstaller.msi
我希望这能正确生成一个 msi 文件,但我收到错误 code error LGHT0307
.
I expect this to properly generate an msi file but i am receiving error code error LGHT0307
.
我已经从蜡烛命令行中删除了 CustomActino.dll 和 CustomAction.CA.dll.我已删除 C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll 并将 -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" 包含到 light 命令中.目前我收到此错误"light.exe : error LGHT0144 : The extension 'C:\Program Files (x86)\WiX Toolset v3.11\bin' 无法加载,原因如下:无法加载文件或程序集file:///C:\Program Files (x86)\WiX Toolset v3.11\bin"或其依赖项之一.拒绝访问."
I have removed CustomActino.dll and CustomAction.CA.dll from the candle command line. I have removed C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll and included -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the light command. Currently i am receiving this error " light.exe : error LGHT0144 : The extension 'C:\Program Files (x86)\WiX Toolset v3.11\bin' could not be loaded because of the following reason: Could not load file or assembly 'file:///C:\Program Files (x86)\WiX Toolset v3.11\bin' or one of its dependencies. Access is denied."
这是新的命令行:"%WIX%bin\light" obj\Debug*.wixobj -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" -ext WixIIsExtension -ext WixNetFxExtension -ext WixUIExtension -ext WixUtilExtension -ext "C:\Users\User1\Documents\testProj\Utils\bin\Debug\Utils.dll" -o obj\Debug\CommandLineInstaller.msi
Here is the new command line: "%WIX%bin\light" obj\Debug*.wixobj -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\WixUIExtension.dll" -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin" -ext WixIIsExtension -ext WixNetFxExtension -ext WixUIExtension -ext WixUtilExtension -ext "C:\Users\User1\Documents\testProj\Utils\bin\Debug\Utils.dll" -o obj\Debug\CommandLineInstaller.msi
推荐答案
MSBuild:大多数人使用 MSBuild - 我相信 - 通过这样的命令行进行构建.WiX 帮助材料中有一节关于使用 MSBuild.
自定义操作 DLL:我在 WiX 源文件中包含了自定义操作 DLL.这是一个在 WiX 源文件中包含硬编码路径的示例,用于说明如何包含自定义操作 dll:
Custom Action DLL: I include custom action DLLs from within the WiX source file. Here is a sample with hard coded paths in the WiX source file for how you can include your custom action dll:
构造:$(env.SystemRoot)
- 在下面的 WiX 源代码中 -获取环境变量 %SystemRoot%
- 解析为C:\
在大多数系统上(要列出环境变量,请打开一个 cmd.exe
并输入 set
并按 Enter
).因此,以下来源应无需修改即可在所有系统上编译:
The construct:
$(env.SystemRoot)
- in the WiX source below - gets the environment variable%SystemRoot%
- which resolves toC:\
on most systems (to list environment variables open acmd.exe
and typeset
and pressEnter
). The below source should hence compile on all systems without modifications:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SimpleCustomAction" Language="1033" Version="1.0.0.0"
Manufacturer="-" UpgradeCode="">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="SimpleCustomAction" Level="1" />
<!-- START: Custom action entries -->
<!-- Hard coded SourceFile path to compiled C# dll Win32 wrapper (MakeSfxCA.exe) -->
<Binary Id="CustomActions" SourceFile="C:\CustomAction1.CA.dll" />
<!-- BinaryKey => Use Binary element Id from above entry-->
<!-- DllEntry => Exported method name inside dll (C# method name) -->
<CustomAction Id="SimpleCustomAction" BinaryKey="CustomActions" DllEntry="CustomAction1"/>
<!-- Run custom action -->
<InstallExecuteSequence>
<Custom Action="SimpleCustomAction" After="CostFinalize" />
</InstallExecuteSequence>
<!-- END: Custom action entries -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SimpleCustomAction">
<Component Feature="ProductFeature">
<File Source="$(env.SystemRoot)\notepad.exe" />
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
批量构建:这就足够了,不需要在 candle.exe
和 light.exe
命令来构建 MSI.以下是一些示例命令:
Batch Build: This should suffice, no need to specify anything in the candle.exe
and light.exe
commands to build the MSI. Here are some sample commands:
"%WIX%bin\candle.exe" product.wxs -ext WixUIExtension >> Build.log
"%WIX%bin\light.exe" -out Test.msi product.wixobj -ext WixUIExtension >> Build.log
这篇关于Light.exe 错误 LGHT0307 'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute' 未在程序集中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!