From bdea82e7d548e0c9d3b895293591b51642257771 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 11 Apr 2016 13:51:35 -0500 Subject: [PATCH 1/2] Making Config values lazy loaded so UpdateFiles can be run without setting the GitHub env vars. --- scripts/update-dependencies/Config.cs | 52 +++++++++++++-------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/scripts/update-dependencies/Config.cs b/scripts/update-dependencies/Config.cs index 7772bba52..72230e94a 100644 --- a/scripts/update-dependencies/Config.cs +++ b/scripts/update-dependencies/Config.cs @@ -27,38 +27,36 @@ namespace Microsoft.DotNet.Scripts /// public class Config { - public static Config Instance { get; } = Read(); + public static Config Instance { get; } = new Config(); - public string UserName { get; set; } - public string Email { get; set; } - public string Password { get; set; } - public string CoreFxVersionUrl { get; set; } - public string GitHubOriginOwner { get; set; } - public string GitHubUpstreamOwner { get; set; } - public string GitHubProject { get; set; } - public string GitHubUpstreamBranch { get; set; } - public string[] GitHubPullRequestNotifications { get; set; } + private Lazy _userName = new Lazy(() => GetEnvironmentVariable("GITHUB_USER")); + private Lazy _email = new Lazy(() => GetEnvironmentVariable("GITHUB_EMAIL")); + private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); + + private Lazy _coreFxVersionUrl = new Lazy(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/dotnet/corefx/release/1.0.0-rc2/LKG.txt")); + private Lazy _gitHubOriginOwner; + 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", "rel/1.0.0")); + private Lazy _gitHubPullRequestNotifications = new Lazy(() => + GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "") + .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); - private static Config Read() + private Config() { - string userName = GetEnvironmentVariable("GITHUB_USER"); - - return new Config - { - UserName = userName, - Email = GetEnvironmentVariable("GITHUB_EMAIL"), - Password = GetEnvironmentVariable("GITHUB_PASSWORD"), - - CoreFxVersionUrl = GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/dotnet/corefx/release/1.0.0-rc2/LKG.txt"), - GitHubOriginOwner = GetEnvironmentVariable("GITHUB_ORIGIN_OWNER", userName), - GitHubUpstreamOwner = GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet"), - GitHubProject = GetEnvironmentVariable("GITHUB_PROJECT", "cli"), - GitHubUpstreamBranch = GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "rel/1.0.0"), - GitHubPullRequestNotifications = GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "") - .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - }; + _gitHubOriginOwner = new Lazy(() => GetEnvironmentVariable("GITHUB_ORIGIN_OWNER", UserName)); } + public string UserName => _userName.Value; + public string Email => _email.Value; + public string Password => _password.Value; + public string CoreFxVersionUrl => _coreFxVersionUrl.Value; + public string GitHubOriginOwner => _gitHubOriginOwner.Value; + public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value; + public string GitHubProject => _gitHubProject.Value; + public string GitHubUpstreamBranch => _gitHubUpstreamBranch.Value; + public string[] GitHubPullRequestNotifications => _gitHubPullRequestNotifications.Value; + private static string GetEnvironmentVariable(string name, string defaultValue = null) { string value = Environment.GetEnvironmentVariable(name); From d0fe815ae9065887e14528fb1a05f57a0ade24d6 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 11 Apr 2016 14:01:59 -0500 Subject: [PATCH 2/2] Add pretemplates to UpdateFiles script. The pretemplate files can still have CoreFX versions in them, which need to be updated. --- scripts/update-dependencies/UpdateFilesTargets.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/update-dependencies/UpdateFilesTargets.cs b/scripts/update-dependencies/UpdateFilesTargets.cs index 3c59592e2..ec94e39f6 100644 --- a/scripts/update-dependencies/UpdateFilesTargets.cs +++ b/scripts/update-dependencies/UpdateFilesTargets.cs @@ -57,7 +57,9 @@ namespace Microsoft.DotNet.Scripts { List dependencyInfos = c.GetDependencyInfos(); - IEnumerable projectJsonFiles = Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories); + IEnumerable projectJsonFiles = Enumerable.Union( + Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories), + Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.pretemplate", SearchOption.AllDirectories)); JObject projectRoot; foreach (string projectJsonFile in projectJsonFiles)