Walker News

How To Set C# Program Version Number At Command Prompt?

Ever wonder how to use C# command-line compiler (csc.exe) to set or add application version number as you build the .Net program at Windows Command Prompt?

Well, you can set the application build version number, product name, copyright, trademark, etc, in AssemblyInfo.cs and compile it together with the program source code:



Uses AssemblyInfo.cs to add .Net Program build version number and misc. properties

The sample of AssemblyInfo.cs (simplified version of template given by Microsoft Visual C# 2010 Express):
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Windows Filesystem Logger")]
[assembly: AssemblyProduct("WFSLog")]
[assembly: AssemblyCopyright("Copyright © WalkerNews.net")]
[assembly: AssemblyTrademark("WalkerNews.net")]
[assembly: AssemblyVersion("1.0.0.9")]
[assembly: AssemblyFileVersion("1.0.0.9")]

As you compile the main program source code at Windows Command Prompt window using csc.exe, make sure AssemblyInfo.cs is included.

Let’s say the WFSLog.cs (source code of wfslog) and AssemblyInfo.cs are both in the same folder, then the C# command-line compiler syntax will be:
csc /win32icon:favicon.ico *.cs

where /win32icon is optional option switch used to add user-defined icon to the compiled .Net program.

Custom Search

2017  •  Privacy Policy