// Copyright (c) James Jackson-South and contributors.
usingSystem.IO;
// Licensed under the Apache License, Version 2.0.
usingSystem.Linq;
// </copyright>
usingNuGet.Versioning;
usingSystem.Collections.Generic;
usingLibGit2Sharp;
usingNewtonsoft.Json;
usingSystem.Text;
namespaceConsoleApplication
namespaceConsoleApplication
{
{
usingSystem;
usingSystem.Collections.Generic;
usingSystem.IO;
usingSystem.Linq;
usingSystem.Text;
usingLibGit2Sharp;
usingMicrosoft.DotNet.ProjectModel;
usingNewtonsoft.Json;
usingNuGet.Versioning;
/// <summary>
/// <summary>
/// This updates the version numbers for all the projects in the src folder.
/// This updates the version numbers for all the projects in the src folder.
/// The version number it will geneate is dependent on if this is a build from master or a branch/PR
/// The version number it will geneate is dependent on if this is a build from master or a branch/PR
///
///
/// If its a build on master
/// If its a build on master
/// We take the version number specified in project.json,
/// We take the version number specified in project.json,
/// count how meny commits the repo has had that will affect this project or its dependencies since the version number of manually changed
/// count how meny commits the repo has had that will affect this project or its dependencies since the version number of manually changed
/// If this is the first commit that effected this project since number change then leave the version number as defined i.e. will build 1.0.0 if thats in project.json
/// If this is the first commit that effected this project since number change then leave the version number as defined i.e. will build 1.0.0 if thats in project.json
/// unless it is a preview build number in which case we always add the counter
/// unless it is a preview build number in which case we always add the counter
///
///
/// If the build is from a PR/branch
/// If the build is from a PR/branch
/// We take the version number specified in project.json, append a tag for the branch/PR (so we can determin how each package was built)
/// We take the version number specified in project.json, append a tag for the branch/PR (so we can determin how each package was built)
/// append number of commits effecting the project.
/// append number of commits effecting the project.
///
///
/// Examples
/// </summary>
/// <example>
/// for PR#123 and project.json version 2.0.1 and we have had 30 commits affecting the project
/// for PR#123 and project.json version 2.0.1 and we have had 30 commits affecting the project
/// we would end up with version number 2.0.1-PR124-00030
/// we would end up with version number 2.0.1-PR124-00030
///
///
/// for branch `fix-stuff` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// for branch `fix-stuff` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// we would end up with version number 2.0.1-alpha1-fix-stuff-00832
/// we would end up with version number 2.0.1-alpha1-fix-stuff-00832
///
///
/// for `master` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// for `master` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// we would end up with version number 2.0.1-alpha1-00832
/// we would end up with version number 2.0.1-alpha1-00832
///
///
/// for `master` project.json version 2.0.1 and we have had 132 commits affecting the project
/// for `master` project.json version 2.0.1 and we have had 132 commits affecting the project
/// we would end up with version number 2.0.1-CI-00132
/// we would end up with version number 2.0.1-CI-00132
///
///
/// for `master` project.json version 2.0.1 and we have had 1 commits affecting the project
/// for `master` project.json version 2.0.1 and we have had 1 commits affecting the project
/// we would end up with version number 2.0.1
/// we would end up with version number 2.0.1
///
///
/// for `master` project.json version 2.0.1-alpha1 and we have had 1 commits affecting the project
/// for `master` project.json version 2.0.1-alpha1 and we have had 1 commits affecting the project
/// we would end up with version number 2.0.1-alpha1
/// we would end up with version number 2.0.1-alpha1
/// </summary>
/// </example>
/// <remarks>
/// TODO Add the option for using this to update the version numbers in a project and its dependent references.
/// </remarks>
publicclassProgram
publicclassProgram
{
{
conststringfallbackTag="CI";
privateconststringFallbackTag="CI";
/// <summary>
/// Main entry point.
/// </summary>
/// <param name="args">The arguments.</param>
publicstaticvoidMain(string[]args)
publicstaticvoidMain(string[]args)
{
{
// TODO add options to updating the version number for indirvidual projects