From 748516bb0dd78bce36db53f5f08c738ea0f252bc Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 7 Jun 2016 12:14:14 -0500 Subject: [PATCH] Add CoreClr dependency to CLI's update-dependencies. --- build_projects/update-dependencies/Config.cs | 3 ++ .../update-dependencies/UpdateFilesTargets.cs | 38 ++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index f495e2bcc..1221d2d00 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Scripts /// The following Environment Variables can optionally be specified: /// /// COREFX_VERSION_URL - The Url to get the current CoreFx package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt") + /// CORECLR_VERSION_URL - The Url to get the current CoreCLR version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0/Latest_Packages.txt") /// ROSLYN_VERSION_URL - The Url to get the current Roslyn version. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0/Latest_Packages.txt") /// CORESETUP_VERSION_URL - The Url to get the current dotnet/core-setup package versions. (ex. "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0/Latest_Packages.txt") /// GITHUB_ORIGIN_OWNER - The owner of the GitHub fork to push the commit and create the PR from. (ex. "dotnet-bot") @@ -36,6 +37,7 @@ namespace Microsoft.DotNet.Scripts private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); private Lazy _coreFxVersionUrl = new Lazy(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0/Latest_Packages.txt")); + private Lazy _coreClrVersionUrl = new Lazy(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0/Latest_Packages.txt")); private Lazy _roslynVersionUrl = new Lazy(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0/Latest_Packages.txt")); private Lazy _coreSetupVersionUrl = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0/Latest_Packages.txt")); private Lazy _gitHubOriginOwner; @@ -55,6 +57,7 @@ namespace Microsoft.DotNet.Scripts public string Email => _email.Value; public string Password => _password.Value; public string CoreFxVersionUrl => _coreFxVersionUrl.Value; + public string CoreClrVersionUrl => _coreClrVersionUrl.Value; public string RoslynVersionUrl => _roslynVersionUrl.Value; public string CoreSetupVersionUrl => _coreSetupVersionUrl.Value; public string GitHubOriginOwner => _gitHubOriginOwner.Value; diff --git a/build_projects/update-dependencies/UpdateFilesTargets.cs b/build_projects/update-dependencies/UpdateFilesTargets.cs index 0b5d55de2..a86943993 100644 --- a/build_projects/update-dependencies/UpdateFilesTargets.cs +++ b/build_projects/update-dependencies/UpdateFilesTargets.cs @@ -32,6 +32,7 @@ namespace Microsoft.DotNet.Scripts List dependencyInfos = c.GetDependencyInfos(); dependencyInfos.Add(CreateDependencyInfo("CoreFx", Config.Instance.CoreFxVersionUrl).Result); + dependencyInfos.Add(CreateDependencyInfo("CoreClr", Config.Instance.CoreClrVersionUrl).Result); dependencyInfos.Add(CreateDependencyInfo("Roslyn", Config.Instance.RoslynVersionUrl).Result); dependencyInfos.Add(CreateDependencyInfo("CoreSetup", Config.Instance.CoreSetupVersionUrl).Result); @@ -210,19 +211,15 @@ namespace Microsoft.DotNet.Scripts { ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", fileContents => { - DependencyInfo coreFXInfo = c.GetCoreFXDependency(); - - fileContents = ReplaceDependencyVersion(fileContents, coreFXInfo, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR"); + fileContents = ReplaceDependencyVersion(c, fileContents, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR"); return fileContents; }); ReplaceFileContents(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", fileContents => { - DependencyInfo coreSetupInfo = c.GetCoreSetupDependency(); - - fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedFrameworkVersion", "Microsoft.NETCore.App"); - fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedHostVersion", "Microsoft.NETCore.DotNetHost"); + fileContents = ReplaceDependencyVersion(c, fileContents, "SharedFrameworkVersion", "Microsoft.NETCore.App"); + fileContents = ReplaceDependencyVersion(c, fileContents, "SharedHostVersion", "Microsoft.NETCore.DotNetHost"); return fileContents; }); @@ -230,32 +227,29 @@ namespace Microsoft.DotNet.Scripts return c.Success(); } - private static DependencyInfo GetCoreFXDependency(this BuildTargetContext c) - { - return c.GetDependencyInfos().Single(d => d.Name == "CoreFx"); - } - - private static DependencyInfo GetCoreSetupDependency(this BuildTargetContext c) - { - return c.GetDependencyInfos().Single(d => d.Name == "CoreSetup"); - } - - private static string ReplaceDependencyVersion(string fileContents, DependencyInfo dependencyInfo, string dependencyPropertyName, string packageId) + private static string ReplaceDependencyVersion(BuildTargetContext c, string fileContents, string dependencyPropertyName, string packageId) { Regex regex = new Regex($@"{dependencyPropertyName} = ""(?.*)"";"); + string newVersion = c.GetNewVersion(packageId); - string newVersion = dependencyInfo - .NewVersions + return regex.ReplaceGroupValue(fileContents, "version", newVersion); + } + + private static string GetNewVersion(this BuildTargetContext c, string packageId) + { + string newVersion = c.GetDependencyInfos() + .SelectMany(d => d.NewVersions) .FirstOrDefault(p => p.Id == packageId) ?.Version .ToNormalizedString(); if (string.IsNullOrEmpty(newVersion)) { - throw new InvalidOperationException($"Could not find package version information for '{packageId}'"); + c.Error($"Could not find package version information for '{packageId}'"); + return $"DEPENDENCY '{packageId}' NOT FOUND"; } - return regex.ReplaceGroupValue(fileContents, "version", newVersion); + return newVersion; } private static void ReplaceFileContents(string repoRelativePath, Func replacement)