diff --git a/src/core-sdk-tasks/CalculateTemplateVersions.cs b/src/core-sdk-tasks/CalculateTemplateVersions.cs index 478eeebb4..abbc987fe 100644 --- a/src/core-sdk-tasks/CalculateTemplateVersions.cs +++ b/src/core-sdk-tasks/CalculateTemplateVersions.cs @@ -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}" diff --git a/test/core-sdk-tasks.Tests/CalculateTemplateVerionsTests.cs b/test/core-sdk-tasks.Tests/CalculateTemplateVerionsTests.cs index 6f5ca3919..041337b45 100644 --- a/test/core-sdk-tasks.Tests/CalculateTemplateVerionsTests.cs +++ b/test/core-sdk-tasks.Tests/CalculateTemplateVerionsTests.cs @@ -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"); } }