c# - 为 codeDOM 文件设置文件版本

标签 c# file version 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);

关于c# - 为 codeDOM 文件设置文件版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/623717/

相关文章:

css - Win8 上的字体端IE 版本兼容性调试工具(从IE 8 9 10 11 轻松转换)是什么?

python - 为什么 Python 标准库的某些模块中有 __version__ 字符串?

c# - 在 Asp.Net Core Identity 中创建没有 UserManager 的用户

c# - 如果将类转换为对象,如何获取公共(public)变量值

ios - 如何在 Xcode 中将声音文件添加到您的包中?

java - 为什么 Java 读取大文件的速度比 C++ 快?

java - 开发适用于智能手机和平板电脑的 Android 应用程序

c# - 使用 Entity Framework 在 C# 中违反代码契约(Contract)不变性

c# - 重用排序逻辑

C 有关文件的统计信息,