设置codeDOM文件的文件版本 [英] Setting file version for a codeDOM file

查看:124
本文介绍了设置codeDOM文件的文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找任何为使用codeDOM生成的exe文件设置文件版本的方法。我的总是出来0.0.0.0。编程方式显然是首选,但在这一点上什么都比没有好。

解决方案

编译程序集的版本由AssemblyFileVersion属性控制。你只需要确保在编译时包含它作为CodeDom树的一部分。

您可以通过将属性添加到CodeCompileUnit AssemblyCustomAttributes成员中来设置该属性。

  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);


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.

解决方案

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);

这篇关于设置codeDOM文件的文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆