11 March 2007
PPUtil: A Utility for Publisher Policy Generation
The conventional method
of creating publisher policy (PP) assemblies becomes cumbersome when
dealing with many assemblies, and many earlier versions of assemblies1.
PPUtil is a configuration-based utility for generating PP for many
assemblies/versions. This tool was authored using .NET 2.0, however,
the resultant PP assemblies can be used with .NET 1.0/1.1-compiled
assemblies.
Download
This work is licensed under a
Creative Commons Attribution 3.0 License.
Usage
PPUtil configurationFile outputDirectory
Common Usage Scenarios
- Redirect a specific earlier version of an assembly to a later version;
- Redirect a range of earlier versions of an assembly to a later version.
In both scenarios, resolution of the redirection for the earlier assembly
versions is limited to major/minor version combinations i.e. build and revision numbers are not considered. This is due to the design of the
publisher policy mechanism itself.
Configuration Examples
Redirect a specific earlier version of an assembly to a later version
Use the oldVersion attribute of the bindingRedirect element to
specify the specific earlier version to redirect from. The major/minor
component of the oldVersion will typically correspond to the
oldMajorMinorVersion attribute of the publisherPolicy element.
<publisherPolicy>
<assemblies>
<assembly name="SampleAssembly"
publicKeyToken="baa3201a127d8068"
strongNameKeyPath="SampleKey.snk" >
<publisherPolicies>
<publisherPolicy oldMajorMinorVersion="1.0" version="1.0.0.0">
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
</publisherPolicy>
</publisherPolicies>
</assembly>
</assemblies>
</publisherPolicy>
Redirect a range of earlier versions of an assembly to a later version
Use the oldLowestVersion and oldHighestVersion attributes of the
bindingRedirect element to specify the range of earlier versions to
redirect from.
<publisherPolicy>
<assemblies>
<assembly name="SampleAssembly"
publicKeyToken="baa3201a127d8068"
strongNameKeyPath="SampleKey.snk" >
<publisherPolicies>
<publisherPolicy oldMajorMinorVersion="2.0" version="2.0.0.0">
<bindingRedirect oldLowestVersion="2.0.0.0"
oldHighestVersion="2.1.0.9"
newVersion="2.2.0.0" />
</publisherPolicy>
</publisherPolicies>
</assembly>
</assemblies>
</publisherPolicy>
Tips
- The provided configuration file must include a configuration
section declaration for the publisherPolicy configuration section, as
follows. The utility will also detect the absence of this declaration
and prompt the user accordingly.
<configuration>
<configSections>
<section name="publisherPolicy" type="PublisherPolicyTool.Configuration.PublisherPolicyConfigurationSection, PPUtil" />
</configSections>
...
</configuration>
- The PP assembly itself is versioned. When there are multiple
versions of a PP assembly available, the version with the highest
number is used. In .NET 1.0/1.1 a bug exists in the assembly loader
whereby when determining the PP assembly with the highest number, the version numbers are sorted in alphabetic order, rather than numeric order.
- The same strong name key used to sign the assembly the PP applies to must be used to sign the PP assembly;
- When GACing a PP assembly, the generated PP configuration file must reside in the same folder as the PP assembly;
- To diagnose binding issues, the binding resolution can be traced using fuslogw or output to disk by modifying registry values;
Acknowledgments
The idea of using the managed assembly builder APIs for PP generation was derived from Omers publisher policy generation sample.
Footnotes
1:
Generating PP involves specifying the old version (major and minor
version number resolution) of an assembly that the binding policy
within the PP assembly will be applied to. The old version corresponds
to an earlier version of an assembly that is referenced by dependent
assemblies.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.