Fix CLI updating

This commit is contained in:
Matt Mitchell 2018-03-29 14:43:38 -07:00
parent 6c3a714b5d
commit f4b52ed865
2 changed files with 55 additions and 18 deletions

View file

@ -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<string> _password = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PASSWORD"));
private Lazy<string> _dotNetVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("DOTNET_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info"));
private Lazy<string> _coreSetupVersionFragment = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", GetDefaultCoreSetupVersionFragment()));
private Lazy<string> _roslynVersionFragment = new Lazy<string>(() => GetEnvironmentVariable("ROSLYN_VERSION_FRAGMENT"));
private Lazy<string> _gitHubUpstreamOwner = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet"));
private Lazy<string> _gitHubProject = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli"));
private Lazy<string> _gitHubUpstreamBranch = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", GetDefaultUpstreamBranch()));
@ -48,6 +48,9 @@ namespace Microsoft.DotNet.Scripts
GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "")
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
Lazy<Dictionary<string, string>> _versionFragments = new Lazy<Dictionary<string, string>>(() =>
System.Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().Where(entry => ((string)entry.Key).EndsWith("_VERSION_FRAGMENT")).ToDictionary<DictionaryEntry, string, string>(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<string, string> 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;

View file

@ -24,14 +24,8 @@ namespace Microsoft.DotNet.Scripts
bool onlyUpdate = args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase);
List<BuildInfo> buildInfos = new List<BuildInfo>();
buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false));
if (s_config.HasRoslynVersionFragment)
{
buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false));
}
List<BuildInfo> buildInfos = new List<BuildInfo>(s_config.VersionFragments.Select<KeyValuePair<string, string>, BuildInfo>(fragment =>
GetBuildInfo(fragment.Key, fragment.Value, fetchLatestReleaseFile: false)));
IEnumerable<IDependencyUpdater> updaters = GetUpdaters();
var dependencyBuildInfos = buildInfos.Select(buildInfo =>
@ -90,14 +84,55 @@ namespace Microsoft.DotNet.Scripts
private static IEnumerable<IDependencyUpdater> 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)