Best Practices

Things to consider when creating a package or version on CORE.Drop (best practices)

  • Use semantic versioning (Major.Minor.Revision)

  • Change the AssemblyInfo.cs to reflect the current version

  • In your bin folder, remove all unnecessary files if needed (.pbd files, CORESSO_COOKIES, etc)

  • Compile your build using the Release solution configuration

  • Test that the build works as expected

  • Make use of Version.Bumper if you have multiple csproject files. (See detail instruction below)

  • Reflect version number in the user interface (See below)

Using the Version.Bumper in your solution

Instruction for using version bumper:

  1. Specify a new version number as the input parameter for the UpdateVersions method.

  2. Specify all csproj that you want to overwrite with the new version number, see line 11-16 below.

  3. 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}";

Last updated