Fix host version through out the builds.

Refactor HostVersion into its own class and use it everywhere host
artifacts are created. This includes the
- host nuget packages
- host installers (msi, pkg, deb)
This commit is contained in:
Sridhar Periyasamy 2016-05-03 19:41:48 -07:00 committed by Bryan
parent e77c92e819
commit a01fda9856
9 changed files with 130 additions and 104 deletions

View file

@ -6,8 +6,8 @@ param(
[Parameter(Mandatory=$true)][string]$DotnetHostMSIOutput, [Parameter(Mandatory=$true)][string]$DotnetHostMSIOutput,
[Parameter(Mandatory=$true)][string]$WixRoot, [Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$ProductMoniker, [Parameter(Mandatory=$true)][string]$ProductMoniker,
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion, [Parameter(Mandatory=$true)][string]$SharedHostMSIVersion,
[Parameter(Mandatory=$true)][string]$DotnetCLINugetVersion, [Parameter(Mandatory=$true)][string]$SharedHostNugetVersion,
[Parameter(Mandatory=$true)][string]$Architecture, [Parameter(Mandatory=$true)][string]$Architecture,
[Parameter(Mandatory=$true)][string]$WixObjRoot [Parameter(Mandatory=$true)][string]$WixObjRoot
) )
@ -29,8 +29,8 @@ function RunCandle
-dHostSrc="$SharedHostPublishRoot" ` -dHostSrc="$SharedHostPublishRoot" `
-dMicrosoftEula="$RepoRoot\packaging\osx\clisdk\resources\en.lproj\eula.rtf" ` -dMicrosoftEula="$RepoRoot\packaging\osx\clisdk\resources\en.lproj\eula.rtf" `
-dProductMoniker="$ProductMoniker" ` -dProductMoniker="$ProductMoniker" `
-dBuildVersion="$DotnetMSIVersion" ` -dBuildVersion="$SharedHostMSIVersion" `
-dNugetVersion="$DotnetCLINugetVersion" ` -dNugetVersion="$SharedHostNugetVersion" `
-arch $Architecture ` -arch $Architecture `
"$AuthWsxRoot\host.wxs" ` "$AuthWsxRoot\host.wxs" `
"$AuthWsxRoot\provider.wxs" ` "$AuthWsxRoot\provider.wxs" `

View file

@ -81,10 +81,10 @@ namespace Microsoft.DotNet.Cli.Build
[Target] [Target]
public static BuildTargetResult GenerateStubHostPackages(BuildTargetContext c) public static BuildTargetResult GenerateStubHostPackages(BuildTargetContext c)
{ {
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion"); var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion");
var currentRid = HostPackagePlatformRid; var currentRid = HostPackagePlatformRid;
PrepareDummyRuntimeNuGetPackage(DotNetCli.Stage0); PrepareDummyRuntimeNuGetPackage(DotNetCli.Stage0);
foreach (var hostPackage in buildVersion.LatestHostPackages) foreach (var hostPackage in hostVersion.LatestHostPackages)
{ {
foreach (var rid in HostPackageSupportedRids.Values.Distinct()) foreach (var rid in HostPackageSupportedRids.Values.Distinct())
{ {
@ -105,8 +105,8 @@ namespace Microsoft.DotNet.Cli.Build
[Target(nameof(PrepareTargets.Init))] [Target(nameof(PrepareTargets.Init))]
public static BuildTargetResult RestoreLockedCoreHost(BuildTargetContext c) public static BuildTargetResult RestoreLockedCoreHost(BuildTargetContext c)
{ {
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion"); var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion");
var lockedHostFxrVersion = buildVersion.LockedHostFxrVersion; var lockedHostFxrVersion = hostVersion.LockedHostFxrVersion;
var currentRid = HostPackagePlatformRid; var currentRid = HostPackagePlatformRid;
string projectJson = $@"{{ string projectJson = $@"{{
""dependencies"": {{ ""dependencies"": {{
@ -149,7 +149,7 @@ namespace Microsoft.DotNet.Cli.Build
[Target(nameof(PrepareTargets.Init))] [Target(nameof(PrepareTargets.Init))]
public static BuildTargetResult CompileCoreHost(BuildTargetContext c) public static BuildTargetResult CompileCoreHost(BuildTargetContext c)
{ {
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion"); var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion");
// Generate build files // Generate build files
var cmakeOut = Path.Combine(Dirs.CorehostLatest, "cmake"); var cmakeOut = Path.Combine(Dirs.CorehostLatest, "cmake");
@ -173,7 +173,7 @@ namespace Microsoft.DotNet.Cli.Build
var ridMacro = $"-DCLI_CMAKE_RUNTIME_ID:STRING={rid}"; var ridMacro = $"-DCLI_CMAKE_RUNTIME_ID:STRING={rid}";
var arch = IsWinx86 ? "x86" : "x64"; var arch = IsWinx86 ? "x86" : "x64";
var baseSupportedRid = $"win7-{arch}"; var baseSupportedRid = $"win7-{arch}";
var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={buildVersion.LatestHostPolicyVersion}"; var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={hostVersion.LatestHostPolicyVersion}";
var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}"; var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}";
var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}"; var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}";
@ -215,7 +215,7 @@ namespace Microsoft.DotNet.Cli.Build
"--arch", "--arch",
"x64", "x64",
"--policyver", "--policyver",
buildVersion.LatestHostPolicyVersion, hostVersion.LatestHostPolicyVersion,
"--rid", "--rid",
rid, rid,
"--commithash", "--commithash",
@ -234,9 +234,9 @@ namespace Microsoft.DotNet.Cli.Build
{ {
var arch = IsWinx86 ? "x86" : "x64"; var arch = IsWinx86 ? "x86" : "x64";
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion"); var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion");
var version = buildVersion.NuGetVersion; var hostNugetversion = hostVersion.LatestHostVersion;
var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{hostNugetversion}{Environment.NewLine}";
var pkgDir = Path.Combine(c.BuildContext.BuildDirectory, "pkg"); var pkgDir = Path.Combine(c.BuildContext.BuildDirectory, "pkg");
File.WriteAllText(Path.Combine(pkgDir, "version.txt"), content); File.WriteAllText(Path.Combine(pkgDir, "version.txt"), content);
@ -246,11 +246,11 @@ namespace Microsoft.DotNet.Cli.Build
// Workaround to arg escaping adding backslashes for arguments to .cmd scripts. // Workaround to arg escaping adding backslashes for arguments to .cmd scripts.
.Environment("__WorkaroundCliCoreHostBuildArch", arch) .Environment("__WorkaroundCliCoreHostBuildArch", arch)
.Environment("__WorkaroundCliCoreHostBinDir", Dirs.CorehostLatest) .Environment("__WorkaroundCliCoreHostBinDir", Dirs.CorehostLatest)
.Environment("__WorkaroundCliCoreHostPolicyVer", buildVersion.LatestHostPolicyVersionNoSuffix) .Environment("__WorkaroundCliCoreHostPolicyVer", hostVersion.LatestHostPolicyVersionNoSuffix)
.Environment("__WorkaroundCliCoreHostFxrVer", buildVersion.LatestHostFxrVersionNoSuffix) .Environment("__WorkaroundCliCoreHostFxrVer", hostVersion.LatestHostFxrVersionNoSuffix)
.Environment("__WorkaroundCliCoreHostVer", buildVersion.LatestHostVersionNoSuffix) .Environment("__WorkaroundCliCoreHostVer", hostVersion.LatestHostVersionNoSuffix)
.Environment("__WorkaroundCliCoreHostBuildMajor", buildVersion.LatestHostBuildMajor) .Environment("__WorkaroundCliCoreHostBuildMajor", hostVersion.LatestHostBuildMajor)
.Environment("__WorkaroundCliCoreHostVersionTag", buildVersion.LatestHostPrerelease) .Environment("__WorkaroundCliCoreHostVersionTag", hostVersion.LatestHostPrerelease)
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.Execute() .Execute()
@ -264,15 +264,15 @@ namespace Microsoft.DotNet.Cli.Build
"--hostbindir", "--hostbindir",
Dirs.CorehostLatest, Dirs.CorehostLatest,
"--policyver", "--policyver",
buildVersion.LatestHostPolicyVersionNoSuffix, hostVersion.LatestHostPolicyVersionNoSuffix,
"--fxrver", "--fxrver",
buildVersion.LatestHostFxrVersionNoSuffix, hostVersion.LatestHostFxrVersionNoSuffix,
"--hostver", "--hostver",
buildVersion.LatestHostVersionNoSuffix, hostVersion.LatestHostVersionNoSuffix,
"--build", "--build",
buildVersion.LatestHostBuildMajor, hostVersion.LatestHostBuildMajor,
"--vertag", "--vertag",
buildVersion.LatestHostPrerelease); hostVersion.LatestHostPrerelease);
} }
foreach (var file in Directory.GetFiles(Path.Combine(pkgDir, "bin", "packages"), "*.nupkg")) foreach (var file in Directory.GetFiles(Path.Combine(pkgDir, "bin", "packages"), "*.nupkg"))
{ {
@ -281,7 +281,7 @@ namespace Microsoft.DotNet.Cli.Build
Console.WriteLine($"Copying package {fileName} to artifacts directory {Dirs.CorehostLocalPackages}."); Console.WriteLine($"Copying package {fileName} to artifacts directory {Dirs.CorehostLocalPackages}.");
} }
foreach (var item in buildVersion.LatestHostPackages) foreach (var item in hostVersion.LatestHostPackages)
{ {
var fileFilter = $"runtime.{HostPackagePlatformRid}.{item.Key}.{item.Value}.nupkg"; var fileFilter = $"runtime.{HostPackagePlatformRid}.{item.Key}.{item.Value}.nupkg";
if (Directory.GetFiles(Dirs.CorehostLocalPackages, fileFilter).Length == 0) if (Directory.GetFiles(Dirs.CorehostLocalPackages, fileFilter).Length == 0)

View file

@ -65,7 +65,7 @@ namespace Microsoft.DotNet.Cli.Build
public static BuildTargetResult GenerateSharedHostDeb(BuildTargetContext c) public static BuildTargetResult GenerateSharedHostDeb(BuildTargetContext c)
{ {
var packageName = Monikers.GetDebianSharedHostPackageName(c); var packageName = Monikers.GetDebianSharedHostPackageName(c);
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion; var version = c.BuildContext.Get<HostVersion>("HostVersion").LockedHostVersion;
var inputRoot = c.BuildContext.Get<string>("SharedHostPublishRoot"); var inputRoot = c.BuildContext.Get<string>("SharedHostPublishRoot");
var debFile = c.BuildContext.Get<string>("SharedHostInstallerFile"); var debFile = c.BuildContext.Get<string>("SharedHostInstallerFile");
var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sharedhost"); var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sharedhost");
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.Cli.Build
Directory.CreateDirectory(objRoot); Directory.CreateDirectory(objRoot);
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-sharedhost-debian.sh"), Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-sharedhost-debian.sh"),
"--input", inputRoot, "--output", debFile, "-b", Monikers.SharedFxBrandName, "--input", inputRoot, "--output", debFile, "-b", Monikers.SharedHostBrandName,
"--obj-root", objRoot, "--version", version, "-m", manPagesDir) "--obj-root", objRoot, "--version", version, "-m", manPagesDir)
.Execute() .Execute()
.EnsureSuccessful(); .EnsureSuccessful();

View file

@ -138,6 +138,9 @@ namespace Microsoft.DotNet.Cli.Build
[BuildPlatforms(BuildPlatform.Windows)] [BuildPlatforms(BuildPlatform.Windows)]
public static BuildTargetResult GenerateDotnetSharedHostMsi(BuildTargetContext c) public static BuildTargetResult GenerateDotnetSharedHostMsi(BuildTargetContext c)
{ {
var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion");
var hostMsiVersion = hostVersion.GenerateMsiVersion();
var hostNugetVersion = hostVersion.LockedHostVersion;
var inputDir = c.BuildContext.Get<string>("SharedHostPublishRoot"); var inputDir = c.BuildContext.Get<string>("SharedHostPublishRoot");
var wixObjRoot = Path.Combine(Dirs.Output, "obj", "wix", "sharedhost"); var wixObjRoot = Path.Combine(Dirs.Output, "obj", "wix", "sharedhost");
var sharedHostBrandName = $"'{Monikers.SharedHostBrandName}'"; var sharedHostBrandName = $"'{Monikers.SharedHostBrandName}'";
@ -150,7 +153,7 @@ namespace Microsoft.DotNet.Cli.Build
Cmd("powershell", "-NoProfile", "-NoLogo", Cmd("powershell", "-NoProfile", "-NoLogo",
Path.Combine(Dirs.RepoRoot, "packaging", "windows", "host", "generatemsi.ps1"), Path.Combine(Dirs.RepoRoot, "packaging", "windows", "host", "generatemsi.ps1"),
inputDir, SharedHostMsi, WixRoot, sharedHostBrandName, MsiVersion, CliNugetVersion, Arch, wixObjRoot) inputDir, SharedHostMsi, WixRoot, sharedHostBrandName, hostMsiVersion, hostNugetVersion, Arch, wixObjRoot)
.Execute() .Execute()
.EnsureSuccessful(); .EnsureSuccessful();
return c.Success(); return c.Success();

View file

@ -28,8 +28,7 @@ namespace Microsoft.DotNet.Cli.Build
PkgsIntermediateDir = Path.Combine(Dirs.Packages, "intermediate"); PkgsIntermediateDir = Path.Combine(Dirs.Packages, "intermediate");
Directory.CreateDirectory(PkgsIntermediateDir); Directory.CreateDirectory(PkgsIntermediateDir);
var hostVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").ProductionVersion; SharedHostComponentId = $"com.microsoft.dotnet.sharedhost.component.osx.x64";
SharedHostComponentId = $"com.microsoft.dotnet.sharedhost.{hostVersion}.component.osx.x64";
string sharedFrameworkNugetName = Monikers.SharedFrameworkName; string sharedFrameworkNugetName = Monikers.SharedFrameworkName;
SharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion"); SharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
@ -171,7 +170,7 @@ namespace Microsoft.DotNet.Cli.Build
[BuildPlatforms(BuildPlatform.OSX)] [BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c) public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c)
{ {
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion; string version = c.BuildContext.Get<HostVersion>("HostVersion").LockedHostVersion;
string outFilePath = Path.Combine(PkgsIntermediateDir, SharedHostComponentId + ".pkg"); string outFilePath = Path.Combine(PkgsIntermediateDir, SharedHostComponentId + ".pkg");
string installLocation = "/usr/local/share/dotnet"; string installLocation = "/usr/local/share/dotnet";
string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedhost", "scripts"); string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedhost", "scripts");

View file

@ -78,7 +78,14 @@ namespace Microsoft.DotNet.Cli.Build
ReleaseSuffix = branchInfo["RELEASE_SUFFIX"], ReleaseSuffix = branchInfo["RELEASE_SUFFIX"],
CommitCount = commitCount CommitCount = commitCount
}; };
var hostVersion = new HostVersion()
{
CommitCount = commitCount
};
c.BuildContext["BuildVersion"] = buildVersion; c.BuildContext["BuildVersion"] = buildVersion;
c.BuildContext["HostVersion"] = hostVersion;
c.BuildContext["CommitHash"] = commitHash; c.BuildContext["CommitHash"] = commitHash;
c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion; c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion;
@ -143,9 +150,10 @@ namespace Microsoft.DotNet.Cli.Build
var cliVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion; var cliVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
var sharedFrameworkVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion"); var sharedFrameworkVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
var hostVersion = c.BuildContext.Get<HostVersion>("HostVersion").LockedHostVersion;
AddInstallerArtifactToContext(c, "dotnet-sdk", "Sdk", cliVersion); AddInstallerArtifactToContext(c, "dotnet-sdk", "Sdk", cliVersion);
AddInstallerArtifactToContext(c, "dotnet-host", "SharedHost", cliVersion); AddInstallerArtifactToContext(c, "dotnet-host", "SharedHost", hostVersion);
AddInstallerArtifactToContext(c, "dotnet-sharedframework", "SharedFramework", sharedFrameworkVersion); AddInstallerArtifactToContext(c, "dotnet-sharedframework", "SharedFramework", sharedFrameworkVersion);
AddInstallerArtifactToContext(c, "dotnet-dev", "CombinedFrameworkSDKHost", cliVersion); AddInstallerArtifactToContext(c, "dotnet-dev", "CombinedFrameworkSDKHost", cliVersion);
AddInstallerArtifactToContext(c, "dotnet", "CombinedFrameworkHost", sharedFrameworkVersion); AddInstallerArtifactToContext(c, "dotnet", "CombinedFrameworkHost", sharedFrameworkVersion);

View file

@ -2,82 +2,12 @@
namespace Microsoft.DotNet.Cli.Build namespace Microsoft.DotNet.Cli.Build
{ {
public class BuildVersion public class BuildVersion : Version
{ {
public int Major { get; set; }
public int Minor { get; set; }
public int Patch { get; set; }
public int CommitCount { get; set; }
public string CommitCountString => CommitCount.ToString("000000");
public string ReleaseSuffix { get; set; }
public string SimpleVersion => $"{Major}.{Minor}.{Patch}.{CommitCountString}"; public string SimpleVersion => $"{Major}.{Minor}.{Patch}.{CommitCountString}";
public string VersionSuffix => $"{CommitCountString}"; public string VersionSuffix => $"{CommitCountString}";
public string NuGetVersion => $"{Major}.{Minor}.{Patch}-{VersionSuffix}"; public string NuGetVersion => $"{Major}.{Minor}.{Patch}-{VersionSuffix}";
public string NetCoreAppVersion => $"{Major}.{Minor}.{Patch}-rc2-3{CommitCountString}"; public string NetCoreAppVersion => $"{Major}.{Minor}.{Patch}-rc2-3{CommitCountString}";
public string ProductionVersion => $"{Major}.{Minor}.{Patch}"; public string ProductionVersion => $"{Major}.{Minor}.{Patch}";
// ------------------------------------------HOST-VERSIONING-------------------------------------------
//
// Host versions are independent of CLI versions. Moreover, these version numbers
// are baked into the binary and is used to look up a serviced binary replacement.
//
//
// Latest hosts for production of nupkgs.
//
// Version constants without suffix
public string LatestHostVersionNoSuffix => "1.0.1";
public string LatestHostFxrVersionNoSuffix => "1.0.1";
public string LatestHostPolicyVersionNoSuffix => "1.0.1";
public string LatestHostPrerelease => "rc2";
public string LatestHostBuildMajor => $"{CommitCountString}";
public string LatestHostSuffix => $"{LatestHostPrerelease}-{LatestHostBuildMajor}-00";
// Full versions and package information.
private string LatestHostVersion => $"{LatestHostVersionNoSuffix}-{LatestHostSuffix}";
private string LatestHostFxrVersion => $"{LatestHostFxrVersionNoSuffix}-{LatestHostSuffix}";
public string LatestHostPolicyVersion => $"{LatestHostPolicyVersionNoSuffix}-{LatestHostSuffix}";
public Dictionary<string, string> LatestHostPackages => new Dictionary<string, string>()
{
{ "Microsoft.NETCore.DotNetHost", LatestHostVersion },
{ "Microsoft.NETCore.DotNetHostResolver", LatestHostFxrVersion },
{ "Microsoft.NETCore.DotNetHostPolicy", LatestHostPolicyVersion }
};
//
// Locked muxer for consumption in CLI.
//
public bool IsLocked = false; // Set this variable to toggle muxer locking.
public string LockedHostFxrVersion => IsLocked ? "1.0.1-rc2-002468-00" : LatestHostFxrVersion;
//
// -----------------------------------------END-OF-HOST-VERSIONING-------------------------------------
public string GenerateMsiVersion()
{
// MSI versioning
// Encode the CLI version to fit into the MSI versioning scheme - https://msdn.microsoft.com/en-us/library/windows/desktop/aa370859(v=vs.85).aspx
// MSI versions are 3 part
// major.minor.build
// Size(bits) of each part 8 8 16
// So we have 32 bits to encode the CLI version
// Starting with most significant bit this how the CLI version is going to be encoded as MSI Version
// CLI major -> 6 bits
// CLI minor -> 6 bits
// CLI patch -> 6 bits
// CLI commitcount -> 14 bits
var major = Major << 26;
var minor = Minor << 20;
var patch = Patch << 14;
var msiVersionNumber = major | minor | patch | CommitCount;
var msiMajor = (msiVersionNumber >> 24) & 0xFF;
var msiMinor = (msiVersionNumber >> 16) & 0xFF;
var msiBuild = msiVersionNumber & 0xFFFF;
return $"{msiMajor}.{msiMinor}.{msiBuild}";
}
} }
} }

View file

@ -0,0 +1,47 @@
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build
{
public class HostVersion : Version
{
// ------------------------------------------HOST-VERSIONING-------------------------------------------
//
// Host versions are independent of CLI versions. Moreover, these version numbers
// are baked into the binary and is used to look up a serviced binary replacement.
//
//
// Latest hosts for production of nupkgs.
//
// Version constants without suffix
public override int Major => 1;
public override int Minor => 0;
public override int Patch => 1;
public override string ReleaseSuffix => "rc2";
public string LatestHostVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostFxrVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostPolicyVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostPrerelease => ReleaseSuffix;
public string LatestHostBuildMajor => $"{CommitCountString}";
public string LatestHostSuffix => $"{ReleaseSuffix}-{LatestHostBuildMajor}-00";
// Full versions and package information.
public string LatestHostVersion => $"{LatestHostVersionNoSuffix}-{LatestHostSuffix}";
public string LatestHostFxrVersion => $"{LatestHostFxrVersionNoSuffix}-{LatestHostSuffix}";
public string LatestHostPolicyVersion => $"{LatestHostPolicyVersionNoSuffix}-{LatestHostSuffix}";
public Dictionary<string, string> LatestHostPackages => new Dictionary<string, string>()
{
{ "Microsoft.NETCore.DotNetHost", LatestHostVersion },
{ "Microsoft.NETCore.DotNetHostResolver", LatestHostFxrVersion },
{ "Microsoft.NETCore.DotNetHostPolicy", LatestHostPolicyVersion }
};
//
// Locked muxer for consumption in CLI.
//
public bool IsLocked = false; // Set this variable to toggle muxer locking.
public string LockedHostFxrVersion => IsLocked ? "1.0.1-rc2-002468-00" : LatestHostFxrVersion;
public string LockedHostVersion => IsLocked ? "1.0.1-rc2-002468-00" : LatestHostVersion;
}
}

View file

@ -0,0 +1,39 @@
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build
{
public abstract class Version
{
public virtual int Major { get; set; }
public virtual int Minor { get; set; }
public virtual int Patch { get; set; }
public virtual int CommitCount { get; set; }
public virtual string CommitCountString => CommitCount.ToString("000000");
public virtual string ReleaseSuffix { get; set; }
public string GenerateMsiVersion()
{
// MSI versioning
// Encode the CLI version to fit into the MSI versioning scheme - https://msdn.microsoft.com/en-us/library/windows/desktop/aa370859(v=vs.85).aspx
// MSI versions are 3 part
// major.minor.build
// Size(bits) of each part 8 8 16
// So we have 32 bits to encode the CLI version
// Starting with most significant bit this how the CLI version is going to be encoded as MSI Version
// CLI major -> 6 bits
// CLI minor -> 6 bits
// CLI patch -> 6 bits
// CLI commitcount -> 14 bits
var major = Major << 26;
var minor = Minor << 20;
var patch = Patch << 14;
var msiVersionNumber = major | minor | patch | CommitCount;
var msiMajor = (msiVersionNumber >> 24) & 0xFF;
var msiMinor = (msiVersionNumber >> 16) & 0xFF;
var msiBuild = msiVersionNumber & 0xFFFF;
return $"{msiMajor}.{msiMinor}.{msiBuild}";
}
}
}