Cap major 5
This commit is contained in:
parent
8b9a67d117
commit
90b13626ab
2 changed files with 49 additions and 16 deletions
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using NuGet.Versioning;
|
||||
|
@ -49,11 +47,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
var aspNetCoreTemplate = NuGetVersion.Parse(aspNetCorePackageVersionTemplate);
|
||||
|
||||
// due to historical bug https://github.com/dotnet/core-sdk/issues/6243
|
||||
// we need to increase patch version by one in order to "reset" existing install ComponentId
|
||||
// more in the above bug's detail
|
||||
var baseMajorMinorPatch = new NuGetVersion(aspNetCoreTemplate.Major, aspNetCoreTemplate.Minor,
|
||||
aspNetCoreTemplate.Patch + _patchVersionResetOffset);
|
||||
NuGetVersion baseMajorMinorPatch = GetBaseMajorMinorPatch(aspNetCoreTemplate);
|
||||
|
||||
string bundledTemplateInstallPath = aspNetCoreTemplate.IsPrerelease
|
||||
? $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}-{versionSuffix}"
|
||||
|
@ -64,5 +58,23 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
bundledTemplateInstallPath,
|
||||
$"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}");
|
||||
}
|
||||
|
||||
private static NuGetVersion GetBaseMajorMinorPatch(NuGetVersion aspNetCoreTemplate)
|
||||
{
|
||||
// due to historical bug https://github.com/dotnet/core-sdk/issues/6243
|
||||
// we need to increase patch version by one in order to "reset" existing install ComponentId
|
||||
// more in the above bug's detail.
|
||||
// There is no non-deterministic existing ComponentId under Major version 5.
|
||||
// so only apply the patch bump when below 5
|
||||
|
||||
int basePatch =
|
||||
aspNetCoreTemplate.Major < 5
|
||||
? aspNetCoreTemplate.Patch + _patchVersionResetOffset
|
||||
: aspNetCoreTemplate.Patch;
|
||||
|
||||
var baseMajorMinorPatch = new NuGetVersion(aspNetCoreTemplate.Major, aspNetCoreTemplate.Minor,
|
||||
basePatch);
|
||||
return baseMajorMinorPatch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,22 +7,43 @@ namespace EndToEnd
|
|||
public class CalculateTemplateVersionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void ItCanCalculateTemplateVersionsInStableBuilds()
|
||||
public void WhenAspNetCoreTemplateMajorVersionLowerthan3ItCanCalculateTemplateVersionsInStableBuilds()
|
||||
{
|
||||
var result = CalculateTemplateVersions.Calculate("3.1.0", "014885", "dev");
|
||||
result.BundledTemplateInstallPath.Should().Be("3.1.1",
|
||||
"the patch is 1 higher than aspnetTemplateVersion due to https://github.com/dotnet/core-sdk/issues/6243");
|
||||
result.BundledTemplateMsiVersion.Should().Be("3.1.1.014885");
|
||||
result.BundledTemplateMajorMinorVersion.Should().Be("3.1");
|
||||
|
||||
result.Should()
|
||||
.Be(("3.1.1.014885", "3.1.1", "3.1"),
|
||||
"the patch is 1 higher than aspnetTemplateVersion " +
|
||||
"due to https://github.com/dotnet/core-sdk/issues/6243");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItCanCalculateTemplateVersionsInNonStableBuilds()
|
||||
public void WhenAspNetCoreTemplateMajorVersionLowerthan3ItCanCalculateTemplateVersionsInNonStableBuilds()
|
||||
{
|
||||
var result = CalculateTemplateVersions.Calculate("3.0.0-alpha.1.20071.6", "014885", "dev");
|
||||
|
||||
result.Should()
|
||||
.Be(("3.0.1.014885", "3.0.1-dev", "3.0"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenAspNetCoreTemplateMajorVersionHigherthan3ItCanCalculateTemplateVersionsInStableBuilds()
|
||||
{
|
||||
var result = CalculateTemplateVersions.Calculate("5.1.0", "014885", "dev");
|
||||
|
||||
result.Should()
|
||||
.Be(("5.1.0.014885", "5.1.0", "5.1"),
|
||||
"the patch align with AspNetCoreTemplateMajorVersion again, " +
|
||||
"since there is no non-deterministic existing ComponentId under Major version 5.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenAspNetCoreTemplateMajorVersionHigherthan3ItCanCalculateTemplateVersionsInNonStableBuilds()
|
||||
{
|
||||
var result = CalculateTemplateVersions.Calculate("5.0.0-alpha.1.20071.6", "014885", "dev");
|
||||
result.BundledTemplateInstallPath.Should().Be("5.0.1-dev");
|
||||
result.BundledTemplateMsiVersion.Should().Be("5.0.1.014885");
|
||||
result.BundledTemplateMajorMinorVersion.Should().Be("5.0");
|
||||
|
||||
result.Should()
|
||||
.Be(("5.0.0.014885", "5.0.0-dev", "5.0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue