Current year in AssemblyInfo copyright


Is there a possibility to include the current year via DateTime.Now.Year in the AssemblyInfo.cs-file?

I have tried:

[assembly: AssemblyCopyright("Copyright " + DateTime.Now.Year)]

But it seems the argument can only be a constant expression.

Best Solution

This can be automated, but you'll need to use a method which manipulates the AssemblyInfo.cs file pre-build.

Should you be doing this though?

A term of copyright doesn't restart when you rebuild your code. If the copyright is currently 2009 it should remain at 2009 regardless of the current year, unless you make significant* code changes in a later year.

*For the value of 'significant' you need to consult a lawyer, not a software developer.

Related Question