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
  • 94,086
  • 102
  • 195
  • 339
lf80
  • 1
  • 1
  • 7
  • 19

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
  • 123,782
  • 12
  • 99
  • 138