Which would be the proper way to install one publisher policy in to the GAC using WIX?

865 views Asked by At

Which would be the proper way to install one publisher policy in to the GAC using WIX 3.5?

I tried to do this:

      <File
            Id="LIBGAC"
            Assembly=".net"
            KeyPath="yes"
            Vital="yes"
            Name="ClassLibrary1.dll"
            ProcessorArchitecture="msil"
            DiskId="1"
            Source="..\ClassLibrary1\bin\Release\ClassLibrary1.dll"  >
      </File>
    </Component>
    <Component Id="Config"  Guid="F089B1AA-B593-4662-9DF4-F47EB9FBA1F4"  >
      <File
            Id="LIBGACPolicy"
            Assembly=".net"
            KeyPath="yes"
            Vital="yes"
            Name="Policy.1.0.ClassLibrary1.dll"
            DiskId="1"
            Source="..\ClassLibrary1\policy.1.0.ClassLibrary1.dll"  >
      </File>
      <File 
            Id="LIBGACPolicyConfig" 
            Source="..\ClassLibrary1\policy.1.0.ClassLibrary1.config" 
            CompanionFile="LIBGACPolicy">
      </File>
    </Component>
  </Directory>

When compiling with VS2008 appears this error:

policy.1.0.ClassLibrary1.dll appears to be invalid. Please ensure this is a valid assembly file and that the user has the appropriate access rights to this file. More information: HRESULT: 0x8013101b

And lastly, when compiling with VS2010 doesn´t appear to be any problem. But at finalizing the installation process, the DLL is well installed and the publisher policy didn´t. Also I read the log generated during the installation and I wasn´t able to find a cause.

Thanks for reading.

3

There are 3 answers

0
oarrivi On

I've been doing something similar and works well using Visual Studio 2010 and in a Build Server with MsBuild:

<Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="ProgramFilesFolder">
      <Directory Id="Gac" Name="Gac">
         <!-- The component with the assembly -->
         <Component Id="MiClassDLL" Guid="*">
            <File Id="MiClass.dll" Assembly=".net" KeyPath="yes"
                  Source="$(var.MiClass.TargetPath)" />
         </Component>
         <!-- The component with the policy -->
         <Component Id="PolicyMiClassDLL" Guid="{YOUR_GUID_HERE}">
            <File Id="PolicyMiClass.dll" KeyPath="yes"
                  Source="$(var.MiClass.TargetDir)Policy.1.0.MiClass.dll" />
            <File Id="PolicyMiClass.config" KeyPath="no"
                  Source="$(var.MiClass.ProjectDir)Policy.1.0.MiClass.config" />

         </Component>
      </Directory>
   </Directory>        
</Directory

In my case I have the policy.config file in the same project directory and I build the policy dll in the same output to make easier the installer script.

I noticed that the policy component must have a guid and for some reason it requires internally that policy dll and config files in the same directory/component.

I build the policy assembly in the Post-Build event of MiClass project with this command:

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\al.exe"
    /link:"$(ProjectDir)Policy.1.0.MiClass.config"
    /out:"$(TargetDir)Policy.1.0.MiClass.dll"
    /keyfile:"$(SolutionDir)MyKeys.snk"
    /comp:"My Company"
    /prod:"My Product" 
    /productv:1.0 
    /version:1.0.0.0

I hope this works for you.

0
Dave Andersen On

I did some work with policy dlls, and the only difference I can see is that your file naming convention is a little different than ours was.

Instead of

policy.1.0.ClassLibrary1.dll
policy.1.0.ClassLibrary1.config

We used

policy.1.0.ClassLibrary1.dll
ClassLibrary1.dll.config
0
Kakash1hatake On

instead of /link switch use /embed to compile the xml-config into publisher policy. then you can install the resulting assembly into GAC without problems