【问题标题】:Using of updated value in AssemblyInfo.cs在 AssemblyInfo.cs 中使用更新的值
【发布时间】:2019-04-01 14:51:58
【问题描述】:

我正在试图弄清楚如何处理和更新AssemblyInfo.csC# WinForms 桌面应用程序中的值。

例如,在哪里以及如何处理

string currentYear = DateTime.Now.Year.ToString();

并在AssemblyInfo.cs 中更新以始终仅从currentYear 获取特定的.exe -> Properties/Details -> description - Product name 来自

[assembly: AssemblyProduct("Access described according " + currentYear + " year update")]

任何建议、指南或示例都会很有用

【问题讨论】:

    标签: c# winforms datetime assemblyinfo


    【解决方案1】:

    我想你也许可以使用compile-time T4 templates

    我目前使用的是 Mac,因此无法对此进行测试(.NET Core 显然需要不同的工具),但可能会创建一个 AssemblyInfo.cs.tt 文件,其内容类似于

    <#@ template hostspecific="false" language="C#" #>
    <#@ output extension=".cs" #>
    <#
    string currentYear = DateTime.Now.Year.ToString();
    #>
    using System;
    using System.Reflection;
    using System.Resources;
    using System.Runtime.InteropServices;
    
    // [... snip ...]
    [assembly: AssemblyTrademark("Something from year <#= currentYear #>")]
    

    对你有用吗?

    【讨论】:

    • 你好,我不知道如何在 WinForms 中适应这种方式
    猜你喜欢
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 2017-03-15
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    相关资源
    最近更新 更多