Exemplo n.º 1
0
 /// <summary>
 ///   <p>Minimalistic versioning using Git tags.</p>
 ///   <p>For more details, visit the <a href="https://github.com/adamralph/minver">official website</a>.</p>
 /// </summary>
 /// <remarks>
 ///   <p>This is a <a href="http://www.nuke.build/docs/authoring-builds/cli-tools.html#fluent-apis">CLI wrapper with fluent API</a> that allows to modify the following arguments:</p>
 ///   <ul>
 ///     <li><c>--auto-increment</c> via <see cref="MinVerSettings.AutoIncrement"/></li>
 ///     <li><c>--build-metadata</c> via <see cref="MinVerSettings.BuildMetadata"/></li>
 ///     <li><c>--default-pre-release-phase</c> via <see cref="MinVerSettings.DefaultPreReleasePhase"/></li>
 ///     <li><c>--minimum-major-minor</c> via <see cref="MinVerSettings.MinimumMajorMinor"/></li>
 ///     <li><c>--tag-prefix</c> via <see cref="MinVerSettings.TagPrefix"/></li>
 ///     <li><c>--verbosity</c> via <see cref="MinVerSettings.Verbosity"/></li>
 ///   </ul>
 /// </remarks>
 public static (MinVer Result, IReadOnlyCollection <Output> Output) MinVer(MinVerSettings toolSettings = null)
 {
     toolSettings      = toolSettings ?? new MinVerSettings();
     using var process = ProcessTasks.StartProcess(toolSettings);
     process.AssertZeroExitCode();
     return(GetResult(process, toolSettings), process.Output);
 }
Exemplo n.º 2
0
        private static MinVer GetResult(IProcess process, MinVerSettings toolSettings)
        {
            var versionString = process.Output.Select(x => x.Text).Single(x => !x.StartsWith("MinVer:"));

            var version = new MinVer
            {
                MinVerVersion       = versionString,
                MinVerMajor         = versionString.Split('.')[0],
                MinVerMinor         = versionString.Split('.')[1],
                MinVerPatch         = versionString.Split('.')[2].Split('-')[0].Split('+')[0],
                MinVerPreRelease    = versionString.Split('+')[0].Contains('-') ? versionString.Split('+')[0].Split(new[] { '-' }, count: 2)[1] : null,
                MinVerBuildMetadata = versionString.Contains('+') ? versionString.Split(new[] { '+' }, count: 2)[1] : null
            };

            version.AssemblyVersion = $"{version.MinVerMajor}.0.0.0";
            version.FileVersion     = $"{version.MinVerMajor}.{version.MinVerMinor}.{version.MinVerPatch}.0";
            version.PackageVersion  = versionString;
            version.Version         = versionString;

            return(version);
        }