Light.exe error LGHT0307 'Microsoft.Tools.WindowsInstallerXml.AssemblyDefaultWixExtensionAttribute' was not defined in the assembly

后端 未结 2 1469
感动是毒
感动是毒 2020-12-07 05:12

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:

l

相关标签:
2条回答
  • 2020-12-07 05:52

    MSBuild: Most people use MSBuild - I believe - to build via the command line like that. There is a section on using MSBuild in the WiX help material.


    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:

    The construct: $(env.SystemRoot) - in the WiX source below - gets the environment variable %SystemRoot% - which resolves to C:\ on most systems (to list environment variables open a cmd.exe and type set and press Enter). 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>
    

    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
    
    0 讨论(0)
  • 2020-12-07 05:53

    Custom Action DLLs: I think you might need to take out the CustomAction.dll entry in the light.exe command line. Maybe take out all entries and add back one entry at a time. See sample command lines below.

    • CustomAction.dll - Managed Code assembly dll
    • CustomAction.CA.dll - Win32 wrapper dll for managed code dll:CustomAction.dll

    MakeSfxCA.exe: The latter one is what you should include in your MSI. The DTF (Deployment Tools Foundation) tool MakeSfxCA.exe creates this .CA version of your managed DLL. It contains all the necessary config files for your managed dll to run. You can open CustomAction.CA.dll with 7Zip or another, capable compression program to see the content.

    Batch Build: Minimal command line to build WiX project (if you use a default WiX GUI) - and how-to make a simple WiX project in Visual Studio:

     candle.exe product.wxs -ext WixUIExtension
     light.exe -out Test.msi product.wixobj -ext WixUIExtension
    

    Votive: I suppose you could try to build the WiX project in Visual Studio to see what command lines are used for candle.exe and light.exe in the built output window. That should give you a clue what might not be necessary (I suppose that might be what you already did):


    Links:

    • Please see this similar, but slightly different issue
    0 讨论(0)
提交回复
热议问题