Use nuget version to better reduce code
This commit is contained in:
parent
b76a641e4f
commit
fdda58e6ff
1 changed files with 10 additions and 31 deletions
|
@ -2,8 +2,10 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.Build.Framework;
|
using Microsoft.Build.Framework;
|
||||||
using Microsoft.Build.Utilities;
|
using Microsoft.Build.Utilities;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Build
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
{
|
{
|
||||||
|
@ -43,42 +45,19 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
string BundledTemplateMajorMinorVersion) Calculate(string aspNetCorePackageVersionTemplate,
|
string BundledTemplateMajorMinorVersion) Calculate(string aspNetCorePackageVersionTemplate,
|
||||||
string gitCommitCount, string versionSuffix)
|
string gitCommitCount, string versionSuffix)
|
||||||
{
|
{
|
||||||
(bool isStableVersion, string aspNetCoreVersionMajorMinorPatchVersion) =
|
var aspNetCoreTemplate = NuGetVersion.Parse(aspNetCorePackageVersionTemplate);
|
||||||
GetAspNetCoreVersionMajorMinorPatchVersion(aspNetCorePackageVersionTemplate);
|
|
||||||
|
|
||||||
var bundledTemplateMsiVersion = $"{aspNetCoreVersionMajorMinorPatchVersion}.{gitCommitCount}";
|
var baseMajorMinorPatch = new NuGetVersion(aspNetCoreTemplate.Major, aspNetCoreTemplate.Minor,
|
||||||
|
aspNetCoreTemplate.Patch);
|
||||||
|
|
||||||
string bundledTemplateInstallPath = isStableVersion
|
string bundledTemplateInstallPath = aspNetCoreTemplate.IsPrerelease
|
||||||
? aspNetCoreVersionMajorMinorPatchVersion
|
? $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}-{versionSuffix}"
|
||||||
: $"{aspNetCoreVersionMajorMinorPatchVersion}-{versionSuffix}";
|
: $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}";
|
||||||
|
|
||||||
var parsedAspNetCoreVersionMajorMinorPatchVersion =
|
|
||||||
System.Version.Parse(aspNetCoreVersionMajorMinorPatchVersion);
|
|
||||||
var bundledTemplateMajorMinorVersion =
|
|
||||||
$"{parsedAspNetCoreVersionMajorMinorPatchVersion.Major}.{parsedAspNetCoreVersionMajorMinorPatchVersion.Minor}";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
bundledTemplateMsiVersion,
|
$"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}.{gitCommitCount}",
|
||||||
bundledTemplateInstallPath,
|
bundledTemplateInstallPath,
|
||||||
bundledTemplateMajorMinorVersion);
|
$"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}");
|
||||||
}
|
|
||||||
|
|
||||||
private static (bool isStableVersion, string aspNetCoreVersionMajorMinorPatchVersion)
|
|
||||||
GetAspNetCoreVersionMajorMinorPatchVersion(string aspNetCorePackageVersionTemplate)
|
|
||||||
{
|
|
||||||
var indexOfAspNetCoreVersionPreReleaseSeparator = aspNetCorePackageVersionTemplate.IndexOf('-');
|
|
||||||
string aspNetCoreVersionMajorMinorPatchVersion;
|
|
||||||
if (indexOfAspNetCoreVersionPreReleaseSeparator != -1)
|
|
||||||
{
|
|
||||||
aspNetCoreVersionMajorMinorPatchVersion =
|
|
||||||
aspNetCorePackageVersionTemplate.Substring(0, indexOfAspNetCoreVersionPreReleaseSeparator);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aspNetCoreVersionMajorMinorPatchVersion = aspNetCorePackageVersionTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (indexOfAspNetCoreVersionPreReleaseSeparator == -1, aspNetCoreVersionMajorMinorPatchVersion);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue