Adding automatic generation of DefaultRuntimeFrameworkVersions
This commit is contained in:
parent
2af782ff7d
commit
8cc89ea7e5
4 changed files with 87 additions and 6 deletions
39
src/core-sdk-tasks/GenerateDefaultRuntimeFrameworkVersion.cs
Normal file
39
src/core-sdk-tasks/GenerateDefaultRuntimeFrameworkVersion.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// 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 Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Build
|
||||||
|
{
|
||||||
|
public class GenerateDefaultRuntimeFrameworkVersion : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string RuntimePackVersion { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string DefaultRuntimeFrameworkVersion { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
if (NuGetVersion.TryParse(RuntimePackVersion, out var version))
|
||||||
|
{
|
||||||
|
if (version.IsPrerelease && version.Patch == 0)
|
||||||
|
{
|
||||||
|
DefaultRuntimeFrameworkVersion = RuntimePackVersion;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DefaultRuntimeFrameworkVersion = new NuGetVersion(version.Major, version.Minor, 0).ToFullString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,7 @@
|
||||||
<UsingTask TaskName="DotNetDebTool" AssemblyFile="$(CoreSdkTaskDll)" />
|
<UsingTask TaskName="DotNetDebTool" AssemblyFile="$(CoreSdkTaskDll)" />
|
||||||
<UsingTask TaskName="BuildFPMToolPreReqs" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="BuildFPMToolPreReqs" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="GetUseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="GetUseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
|
<UsingTask TaskName="GenerateDefaultRuntimeFrameworkVersion" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="AddMetadataIsPE" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="AddMetadataIsPE" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="Crossgen" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="Crossgen" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="CopyBlobsToLatest" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="CopyBlobsToLatest" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<BundledVersionsPropsFileName>Microsoft.NETCoreSdk.BundledVersions.props</BundledVersionsPropsFileName>
|
<BundledVersionsPropsFileName>Microsoft.NETCoreSdk.BundledVersions.props</BundledVersionsPropsFileName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_NETCoreAppPackageVersion>$(MicrosoftNETCoreAppRuntimePackageVersion)</_NETCoreAppPackageVersion>
|
<_NETCoreAppPackageVersion>$(MicrosoftNETCoreAppRuntimePackageVersion)</_NETCoreAppPackageVersion>
|
||||||
<_NETStandardLibraryPackageVersion>$(NETStandardLibraryRefPackageVersion)</_NETStandardLibraryPackageVersion>
|
<_NETStandardLibraryPackageVersion>$(NETStandardLibraryRefPackageVersion)</_NETStandardLibraryPackageVersion>
|
||||||
|
@ -92,6 +92,19 @@
|
||||||
PropertyName="_UseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion" />
|
PropertyName="_UseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion" />
|
||||||
</GetUseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion>
|
</GetUseBundledNETCoreAppPackageVersionAsDefaultNetCorePatchVersion>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Generate default runtime framework versions
|
||||||
|
-->
|
||||||
|
<GenerateDefaultRuntimeFrameworkVersion RuntimePackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)">
|
||||||
|
<Output TaskParameter="DefaultRuntimeFrameworkVersion" PropertyName="MicrosoftNETCoreAppDefaultRuntimePackageVersion" />
|
||||||
|
</GenerateDefaultRuntimeFrameworkVersion>
|
||||||
|
<GenerateDefaultRuntimeFrameworkVersion RuntimePackVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)">
|
||||||
|
<Output TaskParameter="DefaultRuntimeFrameworkVersion" PropertyName="MicrosoftWindowsDesktopAppDefaultRuntimePackageVersion" />
|
||||||
|
</GenerateDefaultRuntimeFrameworkVersion>
|
||||||
|
<GenerateDefaultRuntimeFrameworkVersion RuntimePackVersion="$(MicrosoftAspNetCoreAppRuntimePackageVersion)">
|
||||||
|
<Output TaskParameter="DefaultRuntimeFrameworkVersion" PropertyName="MicrosoftAspNetCoreAppDefaultRuntimePackageVersion" />
|
||||||
|
</GenerateDefaultRuntimeFrameworkVersion>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
||||||
TargetFrameworkVersion="1.0"
|
TargetFrameworkVersion="1.0"
|
||||||
|
@ -170,7 +183,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<KnownFrameworkReference Include="Microsoft.NETCore.App"
|
<KnownFrameworkReference Include="Microsoft.NETCore.App"
|
||||||
TargetFramework="netcoreapp5.0"
|
TargetFramework="netcoreapp5.0"
|
||||||
RuntimeFrameworkName="Microsoft.NETCore.App"
|
RuntimeFrameworkName="Microsoft.NETCore.App"
|
||||||
DefaultRuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
|
DefaultRuntimeFrameworkVersion="$(MicrosoftNETCoreAppDefaultRuntimePackageVersion)"
|
||||||
LatestRuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
|
LatestRuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
|
||||||
TargetingPackName="Microsoft.NETCore.App.Ref"
|
TargetingPackName="Microsoft.NETCore.App.Ref"
|
||||||
TargetingPackVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
|
TargetingPackVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
|
||||||
|
@ -196,7 +209,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App"
|
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App"
|
||||||
TargetFramework="netcoreapp5.0"
|
TargetFramework="netcoreapp5.0"
|
||||||
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
||||||
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppDefaultRuntimePackageVersion)"
|
||||||
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
||||||
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
||||||
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
||||||
|
@ -208,7 +221,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App.WPF"
|
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App.WPF"
|
||||||
TargetFramework="netcoreapp5.0"
|
TargetFramework="netcoreapp5.0"
|
||||||
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
||||||
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppDefaultRuntimePackageVersion)"
|
||||||
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
||||||
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
||||||
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
||||||
|
@ -221,7 +234,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms"
|
<KnownFrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms"
|
||||||
TargetFramework="netcoreapp5.0"
|
TargetFramework="netcoreapp5.0"
|
||||||
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
RuntimeFrameworkName="Microsoft.WindowsDesktop.App"
|
||||||
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
DefaultRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppDefaultRuntimePackageVersion)"
|
||||||
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
LatestRuntimeFrameworkVersion="$(MicrosoftWindowsDesktopAppRuntimePackageVersion)"
|
||||||
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
TargetingPackName="Microsoft.WindowsDesktop.App.Ref"
|
||||||
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
TargetingPackVersion="$(MicrosoftWindowsDesktopAppRefPackageVersion)"
|
||||||
|
@ -234,7 +247,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<KnownFrameworkReference Include="Microsoft.AspNetCore.App"
|
<KnownFrameworkReference Include="Microsoft.AspNetCore.App"
|
||||||
TargetFramework="netcoreapp5.0"
|
TargetFramework="netcoreapp5.0"
|
||||||
RuntimeFrameworkName="Microsoft.AspNetCore.App"
|
RuntimeFrameworkName="Microsoft.AspNetCore.App"
|
||||||
DefaultRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppRuntimePackageVersion)"
|
DefaultRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppDefaultRuntimePackageVersion)"
|
||||||
LatestRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppRuntimePackageVersion)"
|
LatestRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppRuntimePackageVersion)"
|
||||||
TargetingPackName="Microsoft.AspNetCore.App.Ref"
|
TargetingPackName="Microsoft.AspNetCore.App.Ref"
|
||||||
TargetingPackVersion="$(MicrosoftAspNetCoreAppRefPackageVersion)"
|
TargetingPackVersion="$(MicrosoftAspNetCoreAppRefPackageVersion)"
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using Xunit;
|
||||||
|
using Microsoft.DotNet.Cli.Build;
|
||||||
|
|
||||||
|
namespace EndToEnd
|
||||||
|
{
|
||||||
|
public class GenerateDefaultRuntimeFrameworkVersionTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[InlineData("3.0.0-rtm", "3.0.0-rtm")]
|
||||||
|
[InlineData("3.1.0", "3.1.0")]
|
||||||
|
[InlineData("10.3.10", "10.3.0")]
|
||||||
|
[InlineData("1.1.10-prerelease", "1.1.0")]
|
||||||
|
public void ItGeneratesDefaultVersionBasedOnRuntimePackVersion(string runtimePackVersion, string defaultRuntimeFrameworkVersion)
|
||||||
|
{
|
||||||
|
var generateTask = new GenerateDefaultRuntimeFrameworkVersion()
|
||||||
|
{
|
||||||
|
RuntimePackVersion = runtimePackVersion
|
||||||
|
};
|
||||||
|
|
||||||
|
generateTask
|
||||||
|
.Execute()
|
||||||
|
.Should().BeTrue();
|
||||||
|
|
||||||
|
generateTask.DefaultRuntimeFrameworkVersion.Should().Be(defaultRuntimeFrameworkVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue