简体   繁体   English

在AssemblyInfo.cs中使用更新的值

[英]Using of updated value in AssemblyInfo.cs

I'm trying to figure out, how to process and update value in AssemblyInfo.cs of C# WinForms desktop application. 我想弄清楚如何处理和更新C# WinForms桌面应用程序的AssemblyInfo.cs的值。

For example, where and how to process 例如,在哪里以及如何处理

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

and update in AssemblyInfo.cs to always get only currentYear with particular .exe -> Properties/Details -> description - Product name from 并在AssemblyInfo.cs更新以始终只获得currentYear与特定.exe - > Properties/Details - > description - Product name来自

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

Any advice, guide or example would be useful 任何建议,指南或示例都会有用

I think you might be able to use compile-time T4 templates . 我想你可能能够使用编译时T4模板

I'm currently on a Mac, so I'm unable to test this (.NET Core apparently requires different tools), but maybe creating an AssemblyInfo.cs.tt file with contents like 我目前在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 #>")]

might work for you? 可能适合你?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM