0

I'm trying to figure out, how to process and update value in AssemblyInfo.cs of C# WinForms desktop application.

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

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

Any advice, guide or example would be useful

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
lf80
  • 455
  • 3
  • 10
  • 22

1 Answers1

0

I think you might be able to use compile-time T4 templates.

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

<#@ 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?

AKX
  • 152,115
  • 15
  • 115
  • 172