Finish ComponentID reset

This commit is contained in:
William Li 2020-01-25 17:32:35 -08:00
parent 38ff5b6af1
commit 8b9a67d117
2 changed files with 12 additions and 6 deletions

View file

@ -29,6 +29,8 @@ namespace Microsoft.DotNet.Cli.Build
[Output]
public string BundledTemplateMajorMinorVersion { get; set; }
private const int _patchVersionResetOffset = 1;
public override bool Execute()
{
var result = Calculate(AspNetCorePackageVersionTemplate, GitCommitCount, VersionSuffix);
@ -47,8 +49,11 @@ 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);
aspNetCoreTemplate.Patch + _patchVersionResetOffset);
string bundledTemplateInstallPath = aspNetCoreTemplate.IsPrerelease
? $"{baseMajorMinorPatch.Major}.{baseMajorMinorPatch.Minor}.{baseMajorMinorPatch.Patch}-{versionSuffix}"

View file

@ -4,14 +4,15 @@ using Microsoft.DotNet.Cli.Build;
namespace EndToEnd
{
public class CalculateTemplateVerionsTests
public class CalculateTemplateVersionsTests
{
[Fact]
public void ItCanCalculateTemplateVersionsInStableBuilds()
{
var result = CalculateTemplateVersions.Calculate("3.1.0", "014885", "dev");
result.BundledTemplateInstallPath.Should().Be("3.1.0");
result.BundledTemplateMsiVersion.Should().Be("3.1.0.014885");
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");
}
@ -19,8 +20,8 @@ namespace EndToEnd
public void ItCanCalculateTemplateVersionsInNonStableBuilds()
{
var result = CalculateTemplateVersions.Calculate("5.0.0-alpha.1.20071.6", "014885", "dev");
result.BundledTemplateInstallPath.Should().Be("5.0.0-dev");
result.BundledTemplateMsiVersion.Should().Be("5.0.0.014885");
result.BundledTemplateInstallPath.Should().Be("5.0.1-dev");
result.BundledTemplateMsiVersion.Should().Be("5.0.1.014885");
result.BundledTemplateMajorMinorVersion.Should().Be("5.0");
}
}