问题
I'm looking for ANY means of setting the file version for an exe file generated using codeDOM. Mine always comes out as 0.0.0.0. Programatically would obviously be preferred, but at this point anything would be better than nothing.
回答1:
The version of the compiled assembly is controlled by the AssemblyFileVersion attribute. You just need to make sure this is included as part of your CodeDom tree when you compile.
You can set this by adding the attribute into the CodeCompileUnit AssemblyCustomAttributes member.
CodeCompileUnit unit = CreateMyUnit();
var attribute = new CodeAttributeDeclaration(
new CodeTypeReference(typeof(AssemblyFileVersionAttribute)));
attribute.Arguments.Add(
new CodeAttributeArgument(
new CodePrimitiveExpression("1.1.1.1")));
unit.AssemblyCustomAttributes.Add(attribute);
来源:https://stackoverflow.com/questions/623717/setting-file-version-for-a-codedom-file