Merge pull request #5661 from dotnet/dev/jgoshi/refactorTasks
Refactor tasks used in generate static props files
This commit is contained in:
commit
e9561f949f
9 changed files with 80 additions and 86 deletions
|
@ -1,34 +1,24 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<Target Name="WriteGitCommitInfoProps"
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework">
|
||||
<GetCommitHash RepoRoot="$(RepoRoot)">
|
||||
<GetCommitCount>
|
||||
<Output TaskParameter="CommitCount" PropertyName="GitInfoCommitCount" />
|
||||
</GetCommitCount>
|
||||
|
||||
<GetCommitHash>
|
||||
<Output TaskParameter="CommitHash" PropertyName="GitInfoCommitHash" />
|
||||
</GetCommitHash>
|
||||
|
||||
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)"
|
||||
VersionMajor="$(VersionMajor)"
|
||||
VersionMinor="$(VersionMinor)"
|
||||
VersionPatch="$(VersionPatch)"
|
||||
ReleaseSuffix="$(ReleaseSuffix)">
|
||||
<Output TaskParameter="CommitCount" PropertyName="GitInfoCommitCount" />
|
||||
<Output TaskParameter="MsiVersion" PropertyName="BuildInfoMsiVersion" />
|
||||
<Output TaskParameter="VersionBadgeMoniker" PropertyName="BuildInfoVersionBadgeMoniker" />
|
||||
</GenerateBuildVersionInfo>
|
||||
|
||||
<PropertyGroup>
|
||||
<ShouldOverWriteThePropsFile
|
||||
Condition=" '$(CommitHash)' != '$(GitInfoCommitHash)' Or
|
||||
'$(CommitCount)' != '$(GitInfoCommitCount)' Or
|
||||
'$(MsiVersion)' != '$(BuildInfoMsiVersion)' Or
|
||||
'$(VersionBadgeMoniker)' != '$(BuildInfoVersionBadgeMoniker)' ">true</ShouldOverWriteThePropsFile>
|
||||
Condition=" '$(DefaultCommitCount)' != '$(GitInfoCommitCount)' Or
|
||||
'$(CommitHash)' != '$(GitInfoCommitHash)' ">true</ShouldOverWriteThePropsFile>
|
||||
|
||||
<GitCommitInfoPropsContent>
|
||||
<Project ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<DefaultCommitCount>$(GitInfoCommitCount)</DefaultCommitCount>
|
||||
<CommitHash>$(GitInfoCommitHash)</CommitHash>
|
||||
<CommitCount>$(GitInfoCommitCount)</CommitCount>
|
||||
<MsiVersion>$(BuildInfoMsiVersion)</MsiVersion>
|
||||
<VersionBadgeMoniker>$(BuildInfoVersionBadgeMoniker)</VersionBadgeMoniker>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</GitCommitInfoPropsContent>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Condition=" !Exists('$(HostInfoProps)') "
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework">
|
||||
<!-- Current Runtime Information -->
|
||||
<GetCurrentRuntimeInformation OverrideRid="$(OverrideRid)">
|
||||
<GetCurrentRuntimeInformation>
|
||||
<Output TaskParameter="Rid" PropertyName="HostRid" />
|
||||
<Output TaskParameter="Architecture" PropertyName="HostArchitecture" />
|
||||
<Output TaskParameter="OSName" PropertyName="HostOSName" />
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
<Target Name="InitializeCommonProps"
|
||||
DependsOnTargets="BuildDotnetCliBuildFramework" >
|
||||
|
||||
<!-- Common Properties -->
|
||||
<PropertyGroup>
|
||||
<IsDesktopAvailable>False</IsDesktopAvailable>
|
||||
|
@ -49,6 +48,11 @@
|
|||
<VersionSuffix>$(ReleaseSuffix)-$(CommitCount)</VersionSuffix>
|
||||
<NugetVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)-$(VersionSuffix)</NugetVersion>
|
||||
|
||||
<VersionBadgeMoniker>$(OSName)_$(Architecture)</VersionBadgeMoniker>
|
||||
<VersionBadgeMoniker Condition=" '$(Rid)' == 'ubuntu.16.04-x64' ">Ubuntu_16_04_x64</VersionBadgeMoniker>
|
||||
<VersionBadgeMoniker Condition=" '$(Rid)' == 'fedora.23-x64' ">Fedora_23_x64</VersionBadgeMoniker>
|
||||
<VersionBadgeMoniker Condition=" '$(Rid)' == 'opensuse.13.2-x64' ">openSUSE_13_2_x64</VersionBadgeMoniker>
|
||||
|
||||
<VersionBadge>$(BaseOutputDirectory)/$(VersionBadgeMoniker)_$(Configuration)_version_badge.svg</VersionBadge>
|
||||
<SdkVersion>$(NugetVersion)</SdkVersion>
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
<UsingTask TaskName="DotNetRestorePJ" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="DotNetTest" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="DownloadFile" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateBuildVersionInfo" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateChecksums" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateGuidFromName" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateMsiVersion" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GenerateNuGetPackagesArchiveVersion" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GetCommitCount" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GetCommitHash" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(CLIBuildDll)" />
|
||||
<UsingTask TaskName="MakeRelative" AssemblyFile="$(CLIBuildDll)" />
|
||||
|
|
|
@ -31,6 +31,14 @@
|
|||
<GeneratedInstallers Include="$(SdkInstallerFile);$(CombinedFrameworkSdkHostInstallerFile)" />
|
||||
</ItemGroup>
|
||||
|
||||
<GenerateMsiVersion CommitCount="$(CommitCount)"
|
||||
VersionMajor="$(VersionMajor)"
|
||||
VersionMinor="$(VersionMinor)"
|
||||
VersionPatch="$(VersionPatch)"
|
||||
ReleaseSuffix="$(ReleaseSuffix)">
|
||||
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
|
||||
</GenerateMsiVersion>
|
||||
|
||||
<GenerateGuidFromName Name="$(SdkInstallerFile)">
|
||||
<Output TaskParameter="OutputGuid"
|
||||
PropertyName="SdkInstallerUpgradeCode" />
|
||||
|
|
46
build_projects/dotnet-cli-build/GenerateMsiVersion.cs
Normal file
46
build_projects/dotnet-cli-build/GenerateMsiVersion.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// 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 System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GenerateMsiVersion : Task
|
||||
{
|
||||
[Required]
|
||||
public int CommitCount { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionMajor { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionMinor { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionPatch { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ReleaseSuffix { get; set; }
|
||||
|
||||
[Output]
|
||||
public string MsiVersion { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
var buildVersion = new BuildVersion()
|
||||
{
|
||||
Major = VersionMajor,
|
||||
Minor = VersionMinor,
|
||||
Patch = VersionPatch,
|
||||
ReleaseSuffix = ReleaseSuffix,
|
||||
CommitCount = CommitCount
|
||||
};
|
||||
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,66 +7,11 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class GenerateBuildVersionInfo : ToolTask
|
||||
public class GetCommitCount : ToolTask
|
||||
{
|
||||
[Required]
|
||||
public string RepoRoot { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionMajor { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionMinor { get; set; }
|
||||
|
||||
[Required]
|
||||
public int VersionPatch { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ReleaseSuffix { get; set; }
|
||||
|
||||
[Output]
|
||||
public string CommitCount { get; set; }
|
||||
|
||||
[Output]
|
||||
public string VersionSuffix { get; set; }
|
||||
|
||||
[Output]
|
||||
public string SimpleVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string NugetVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string MsiVersion { get; set; }
|
||||
|
||||
[Output]
|
||||
public string VersionBadgeMoniker { get; set; }
|
||||
|
||||
private int _commitCount;
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
base.Execute();
|
||||
|
||||
var buildVersion = new BuildVersion()
|
||||
{
|
||||
Major = VersionMajor,
|
||||
Minor = VersionMinor,
|
||||
Patch = VersionPatch,
|
||||
ReleaseSuffix = ReleaseSuffix,
|
||||
CommitCount = _commitCount
|
||||
};
|
||||
|
||||
CommitCount = buildVersion.CommitCountString;
|
||||
VersionSuffix = buildVersion.VersionSuffix;
|
||||
SimpleVersion = buildVersion.SimpleVersion;
|
||||
NugetVersion = buildVersion.NuGetVersion;
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
VersionBadgeMoniker = Monikers.GetBadgeMoniker();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override string ToolName
|
||||
{
|
||||
get { return "git"; }
|
||||
|
@ -91,7 +36,12 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override void LogEventsFromTextOutput(string line, MessageImportance importance)
|
||||
{
|
||||
_commitCount = int.Parse(line);
|
||||
var buildVersion = new BuildVersion()
|
||||
{
|
||||
CommitCount = int.Parse(line)
|
||||
};
|
||||
|
||||
CommitCount = buildVersion.CommitCountString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,9 +9,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public class GetCommitHash : ToolTask
|
||||
{
|
||||
[Required]
|
||||
public string RepoRoot { get; set; }
|
||||
|
||||
[Output]
|
||||
public string CommitHash { get; set; }
|
||||
|
||||
|
@ -42,4 +39,4 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
CommitHash = line;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
public class GetCurrentRuntimeInformation : Task
|
||||
{
|
||||
public string OverrideRid { get; set; }
|
||||
|
||||
[Output]
|
||||
public string Rid { get; set; }
|
||||
|
||||
|
@ -22,7 +20,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
public override bool Execute()
|
||||
{
|
||||
Rid = string.IsNullOrEmpty(OverrideRid) ? RuntimeEnvironment.GetRuntimeIdentifier() : OverrideRid;
|
||||
Rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
||||
Architecture = RuntimeEnvironment.RuntimeArchitecture;
|
||||
OSName = Monikers.GetOSShortName();
|
||||
|
||||
|
|
Loading…
Reference in a new issue