public string GenerateVersionInfoFrom(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            var now = DateTime.UtcNow;

            String prereleasePart = null;
            if (context.IsPrerelease)
            {
                //NB! nuget limits prerelease version string to 20 chars, must start with a letter, contrary to semantic versioning standard no dot, no + allowed.
                //ex: 1.2.3-Debug-20130423-1459
                //ex: 1.2.3-RC-20130423-1459
                // note: we cannot use simple iterator for prerelease (alpha-1, alpha-2, etc) as code has not and should not have any information about previous builds.
                prereleasePart = String.Format("-{0}-{1}-{2}",
                    TrimToLength(context.BuildConfiguration, 6), //up to 6 chars
                    //1 char from pattern
                now.ToString("yyyyMMdd"), //8 chars
                    //1 char from pattern
                now.ToString("HHmm") //4 chars
                );
            } //else release version without prerelease part. Ex: "1.2.3"

            return String.Format("{0}.{1}.{2}{3}",
                context.BaseVersion.Major,
                context.BaseVersion.Minor,
                context.BaseVersion.Build,
                prereleasePart
            );
        }
        public string GenerateVersionInfoFrom(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            return String.Format("{0} (on UTC{1} by {2} at {3})",
                context.BuildConfiguration,
                DateTime.UtcNow.ToString("s"),
                Environment.UserName,
                Environment.MachineName);
        }
        public override Version GenerateSystemVersion(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            DateTime buildDate = DateTime.UtcNow;
            var build = DateToVersionNumberCalculation.BuildDatePart(buildDate);
            var revision = DateToVersionNumberCalculation.BuildTimePart(buildDate);

            var baseVersion = context.BaseVersion;
            return new Version(baseVersion.Major, baseVersion.Minor, build, revision);
        }
        public override Version GenerateSystemVersion(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            DateTime now = DateTime.UtcNow;
            var baseVersion = context.BaseVersion;

            //replace just the revision
            int revision = DateToVersionNumberCalculation.BuildDatePart(now); //reuse the logic already built for HumanReadable2SlotTimestampGenerator

            return new Version(baseVersion.Major, baseVersion.Minor, baseVersion.Build, revision);
        }
        public string GenerateVersionInfoFrom(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }

            String customFormat = context.VersionGenerationArgument;
            if (String.IsNullOrEmpty(customFormat)) { throw new ArgumentException("Custom format requested but no format was provided in VersionGenerationArgument.", "context"); }

            var model = new CustomizedVersionModel(context);

            SyntaxSettings settings = new SyntaxSettings()
            {
                BeginTag = "{",
                EndTag = "}",
            };

            var templateEngine = new TemplateProcessingEngine(settings);
            String result = templateEngine.Process(customFormat, model);
            return result;
        }
 public override Version GenerateSystemVersion(VersionGenerationContext context)
 {
     return null;
 }
 String IVersionGenerator.GenerateVersionInfoFrom(VersionGenerationContext context)
 {
     Version version = GenerateSystemVersion(context);
     return version != null ? version.ToString() : null;
 }
 public abstract Version GenerateSystemVersion(VersionGenerationContext context);
        private DateTime FixedUtcNow = DateTime.UtcNow; // to ensure it does not change between multiple calls

        #endregion Fields

        #region Constructors

        public CustomizedVersionModel(VersionGenerationContext context)
        {
            if (context == null) { throw new ArgumentNullException("context"); }
            this.Context = context;
        }