在某些时候,ILMerge已更改,现在它删除了与安全相关的属性。
问题:
the source code中的实施在这里,fwiw:
#region Deal with [ComVisible] and security attributes
var thisAssemblyIsComVisible = GetComVisibleSettingForAssembly(a);
AttributeNode assemblyComVisibleAttribute = null;
if (thisAssemblyIsComVisible != targetAssemblyIsComVisible) {
InstanceInitializer ctor = SystemTypes.ComVisibleAttribute.GetConstructor(SystemTypes.Boolean);
assemblyComVisibleAttribute = new AttributeNode(new MemberBinding(null, ctor), new ExpressionList(new Literal(thisAssemblyIsComVisible, SystemTypes.Boolean)));
}
for (int i = 0, n = a.Attributes == null ? 0 : a.Attributes.Count; i < n; i++) {
AttributeNode aNode = a.Attributes[i];
if (aNode == null) continue;
if (aNode.Type == SystemTypes.ComVisibleAttribute) {
a.Attributes[i] = null;
continue;
}
if (aNode.Type == SystemTypes.SecurityCriticalAttribute
|| aNode.Type == SystemTypes.SecurityTransparentAttribute
|| aNode.Type == SystemTypes.AllowPartiallyTrustedCallersAttribute
|| aNode.Type.FullName.Equals("System.Security.SecurityRules")
) {
WriteToLog("Assembly level attribute '{0}' from assembly '{1}' being deleted from target assembly",
aNode.Type.FullName, a.Name);
a.Attributes[i] = null;
continue;
}
}
#endregion
这会给某些人带来问题:
我想使用ILMerge构建具有AllowPartiallyTrustedCallers
属性的程序集。我曾经这样做(使用较旧版本的ILMerge)并且不知道为什么我不能再这样了。
我可以通过完全不使用ILMerge来做到这一点(即将所有源代码放入一个项目,而不是构建几个要合并的项目),所以我看不出有什么危害,即为什么ILMerge将不再这样做。