Using the Version.Bumper in your solution
Instruction for using version bumper:
Specify a new version number as the input parameter for the UpdateVersions
method.
Specify all csproj that you want to overwrite with the new version number, see line 11-16 below.
Run the UpdateVersions
method.
public static void UpdateVersions(string version)
{
List<string> assemblies = new List<string>();
List<string> projNames = new List<string>();
string clientSolutionDir = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName + @"\";
string assem = @"\Properties\AssemblyInfo.cs";
projNames.Add(clientSolutionDir + "CORE.Drop.Application");
projNames.Add(clientSolutionDir + "CORE.Drop.Interfaces");
projNames.Add(clientSolutionDir + "CORE.Drop.Library");
projNames.Add(clientSolutionDir + "CORE.Drop.UI");
projNames.Add(clientSolutionDir + "CORE.Drop.ViewModels");
projNames.Add(clientSolutionDir + "CORE.Drop.Test");
foreach (var projName in projNames)
{
assemblies.Add(projName + assem);
}
foreach (string assemblyInfo in assemblies)
{
if (File.Exists(assemblyInfo))
{
var lines = System.IO.File.ReadAllLines(assemblyInfo);
List<string> newContent = new List<string>();
foreach (string line in lines)
{
string newLine = line;
if (line.StartsWith("[assembly: AssemblyVersion"))
newLine = String.Format("[assembly: AssemblyVersion(\"{0}\")]", version);
//if (line.StartsWith("[assembly: AssemblyFileVersion"))
// newLine = String.Format("//[assembly: AssemblyFileVersion(\"{0}\")]", version);
newContent.Add(newLine);
}
System.IO.File.WriteAllLines(assemblyInfo, newContent);
}
else
{
try
{
Console.Write($"ERR: Cannot modify {assemblyInfo}" + Environment.NewLine);
//UpdateInstaller(version, clientSolutionDir);
}
catch (Exception exc)
{
Console.Write($"ERR: Cannot modify {assemblyInfo}");
}
}
}
Console.WriteLine("Done updating versions");
Console.ReadKey();
}
Getting version number in the title
If you have a C# application, you can do this:
v = this.GetType().Assembly.GetName().Version;
string versionString = $"{v.Major}.{v.Minor}.{v.Build}";
this.Title = $"CORE.Drop {versionString}";