From f4b52ed86554af29241790fe609d17d344fab925 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Thu, 29 Mar 2018 14:43:38 -0700 Subject: [PATCH 1/2] Fix CLI updating --- build_projects/update-dependencies/Config.cs | 12 ++-- build_projects/update-dependencies/Program.cs | 61 +++++++++++++++---- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index 88c47ee94..e0f4f1450 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -5,6 +5,8 @@ using System; using System.IO; using System.Linq; using System.Xml.Linq; +using System.Collections; +using System.Collections.Generic; namespace Microsoft.DotNet.Scripts { @@ -38,9 +40,7 @@ namespace Microsoft.DotNet.Scripts private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); private Lazy _dotNetVersionUrl = new Lazy(() => GetEnvironmentVariable("DOTNET_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info")); - private Lazy _coreSetupVersionFragment = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", GetDefaultCoreSetupVersionFragment())); - private Lazy _roslynVersionFragment = new Lazy(() => GetEnvironmentVariable("ROSLYN_VERSION_FRAGMENT")); private Lazy _gitHubUpstreamOwner = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet")); private Lazy _gitHubProject = new Lazy(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli")); private Lazy _gitHubUpstreamBranch = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", GetDefaultUpstreamBranch())); @@ -48,6 +48,9 @@ namespace Microsoft.DotNet.Scripts GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "") .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); + Lazy> _versionFragments = new Lazy>(() => + System.Environment.GetEnvironmentVariables().Cast().Where(entry => ((string)entry.Key).EndsWith("_VERSION_FRAGMENT")).ToDictionary(entry => + (string)entry.Key, entry => (string)entry.Value), ); private Config() { } @@ -56,9 +59,8 @@ namespace Microsoft.DotNet.Scripts public string Email => _email.Value; public string Password => _password.Value; public string DotNetVersionUrl => _dotNetVersionUrl.Value; - public string CoreSetupVersionFragment => _coreSetupVersionFragment.Value; - public string RoslynVersionFragment => _roslynVersionFragment.Value; - public bool HasRoslynVersionFragment => !string.IsNullOrEmpty(RoslynVersionFragment); + public Dictionary VersionFragments => _versionFragments.Value; + public bool HasVersionFragment(string repoName) => _versionFragments.Value.ContainsKey($"{repoName}_VERSION_FRAGMENT"); public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value; public string GitHubProject => _gitHubProject.Value; public string GitHubUpstreamBranch => _gitHubUpstreamBranch.Value; diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index 99b77691e..0cabfdc19 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -24,14 +24,8 @@ namespace Microsoft.DotNet.Scripts bool onlyUpdate = args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase); - List buildInfos = new List(); - - buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false)); - - if (s_config.HasRoslynVersionFragment) - { - buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false)); - } + List buildInfos = new List(s_config.VersionFragments.Select, BuildInfo>(fragment => + GetBuildInfo(fragment.Key, fragment.Value, fetchLatestReleaseFile: false))); IEnumerable updaters = GetUpdaters(); var dependencyBuildInfos = buildInfos.Select(buildInfo => @@ -90,14 +84,55 @@ namespace Microsoft.DotNet.Scripts private static IEnumerable GetUpdaters() { string dependencyVersionsPath = Path.Combine("build", "DependencyVersions.props"); - yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftNETCoreAppPackageVersion", "Microsoft.NETCore.App"); - yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetPlatformAbstractionsPackageVersion", "Microsoft.DotNet.PlatformAbstractions"); - yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftExtensionsDependencyModelPackageVersion", "Microsoft.Extensions.DependencyModel"); - - if (s_config.HasRoslynVersionFragment) + + if (s_config.HasVersionFragment("aspnet")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftAspNetCoreAppPackageVersion", "Microsoft.AspNetCore.App"); + } + if (s_config.HasVersionFragment("clicommandlineparser")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetCliCommandLinePackageVersion", "Microsoft.DotNet.Cli.CommandLine"); + } + if (s_config.HasVersionFragment("climigrate")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetProjectJsonMigrationPackageVersion", "Microsoft.DotNet.ProjectJsonMigration"); + } + if (s_config.HasVersionFragment("coresetup")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftNETCoreAppPackageVersion", "Microsoft.NETCore.App"); + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetPlatformAbstractionsPackageVersion", "Microsoft.DotNet.PlatformAbstractions"); + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftExtensionsDependencyModelPackageVersion", "Microsoft.Extensions.DependencyModel"); + } + if (s_config.HasVersionFragment("fsharp")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftFSharpCompilerPackageVersion", "Microsoft.FSharp.Compiler"); + } + if (s_config.HasVersionFragment("msbuild")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftBuildPackageVersion", "Microsoft.Build"); + } + if (s_config.HasVersionFragment("nugetclient")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "NuGetBuildTasksPackageVersion", "NuGet.Build.Tasks"); + } + if (s_config.HasVersionFragment("roslyn")) { yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftCodeAnalysisCSharpPackageVersion", "Microsoft.CodeAnalysis.CSharp"); } + if (s_config.HasVersionFragment("sdk")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftNETSdkPackageVersion", "Microsoft.NET.Sdk"); + } + if (s_config.HasVersionFragment("templating")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetCommonItemTemplatesPackageVersion", "Microsoft.DotNet.Common.ItemTemplates"); + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftDotNetTestProjectTemplates20PackageVersion", "Microsoft.DotNet.Test.ProjectTemplates.2.0"); + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftTemplateEngineCliPackageVersion", "Microsoft.TemplateEngine.Cli"); + } + if (s_config.HasVersionFragment("websdk")) + { + yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftNETSdkWebPackageVersion", "Microsoft.NET.Sdk.Web"); + } } private static IDependencyUpdater CreateRegexUpdater(string repoRelativePath, string propertyName, string packageId) From 19267bd9f1f595460fc0882ff94c17385b853e03 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Thu, 29 Mar 2018 14:44:20 -0700 Subject: [PATCH 2/2] Remove unused Dia package Extend CLI dependency updating Extend CLI's dependency updating to include all repos. At this time, only ASPNet won't work with this, as in prodcon it isn't specifying a branch in the manifest, which means no Latest_Packages.txt gets set. Once this is fixed all upstream repos in CLI should be handled. This will be combined with changes to the versions repo to update the subscriptions for 2.1.3xx CLI. --- build/DependencyVersions.props | 1 - build_projects/update-dependencies/Config.cs | 4 ++-- build_projects/update-dependencies/Program.cs | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index f959ad24d..29d48716e 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -34,7 +34,6 @@ 1.2.1-alpha-002133 $(MicrosoftDotNetProjectJsonMigrationPackageVersion) 0.2.0-beta-62628-01 - 1.6.0-beta2-25304 4.7.0-preview3.5039 $(NuGetBuildTasksPackageVersion) $(NuGetBuildTasksPackageVersion) diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index e0f4f1450..474d7a32a 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -50,7 +50,7 @@ namespace Microsoft.DotNet.Scripts Lazy> _versionFragments = new Lazy>(() => System.Environment.GetEnvironmentVariables().Cast().Where(entry => ((string)entry.Key).EndsWith("_VERSION_FRAGMENT")).ToDictionary(entry => - (string)entry.Key, entry => (string)entry.Value), ); + ((string)entry.Key).Replace("_VERSION_FRAGMENT","").ToLowerInvariant(), entry => (string)entry.Value, StringComparer.OrdinalIgnoreCase)); private Config() { } @@ -60,7 +60,7 @@ namespace Microsoft.DotNet.Scripts public string Password => _password.Value; public string DotNetVersionUrl => _dotNetVersionUrl.Value; public Dictionary VersionFragments => _versionFragments.Value; - public bool HasVersionFragment(string repoName) => _versionFragments.Value.ContainsKey($"{repoName}_VERSION_FRAGMENT"); + public bool HasVersionFragment(string repoName) => _versionFragments.Value.ContainsKey(repoName); public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value; public string GitHubProject => _gitHubProject.Value; public string GitHubUpstreamBranch => _gitHubUpstreamBranch.Value; diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index 0cabfdc19..47c787fc6 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -26,7 +26,6 @@ namespace Microsoft.DotNet.Scripts List buildInfos = new List(s_config.VersionFragments.Select, BuildInfo>(fragment => GetBuildInfo(fragment.Key, fragment.Value, fetchLatestReleaseFile: false))); - IEnumerable updaters = GetUpdaters(); var dependencyBuildInfos = buildInfos.Select(buildInfo => new BuildDependencyInfo(