Setting file version for a codeDOM file

邮差的信 提交于 2019-12-21 22:38:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!