update-dependencies hard-coded values
Read MSBuild property values to get GITHUB_UPSTREAM_BRANCH and CORESETUP_VERSION_FRAGMENT instead of hard-coding them in update-dependencies.
This commit is contained in:
parent
fb1b99c55a
commit
f4c4db4d3a
2 changed files with 38 additions and 5 deletions
|
@ -2,6 +2,9 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Scripts
|
namespace Microsoft.DotNet.Scripts
|
||||||
{
|
{
|
||||||
|
@ -35,11 +38,10 @@ namespace Microsoft.DotNet.Scripts
|
||||||
private Lazy<string> _password = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PASSWORD"));
|
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> _dotNetVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("DOTNET_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info"));
|
||||||
private Lazy<string> _roslynVersionFragment = new Lazy<string>(() => GetEnvironmentVariable("ROSLYN_VERSION_FRAGMENT", "dotnet/roslyn/netcore1.0"));
|
private Lazy<string> _coreSetupVersionFragment = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", GetDefaultCoreSetupVersionFragment()));
|
||||||
private Lazy<string> _coreSetupVersionFragment = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", "dotnet/core-setup/master"));
|
|
||||||
private Lazy<string> _gitHubUpstreamOwner = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet"));
|
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> _gitHubProject = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli"));
|
||||||
private Lazy<string> _gitHubUpstreamBranch = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "master"));
|
private Lazy<string> _gitHubUpstreamBranch = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", GetDefaultUpstreamBranch()));
|
||||||
private Lazy<string[]> _gitHubPullRequestNotifications = new Lazy<string[]>(() =>
|
private Lazy<string[]> _gitHubPullRequestNotifications = new Lazy<string[]>(() =>
|
||||||
GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "")
|
GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "")
|
||||||
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
||||||
|
@ -51,7 +53,6 @@ namespace Microsoft.DotNet.Scripts
|
||||||
public string Email => _email.Value;
|
public string Email => _email.Value;
|
||||||
public string Password => _password.Value;
|
public string Password => _password.Value;
|
||||||
public string DotNetVersionUrl => _dotNetVersionUrl.Value;
|
public string DotNetVersionUrl => _dotNetVersionUrl.Value;
|
||||||
public string RoslynVersionFragment => _roslynVersionFragment.Value;
|
|
||||||
public string CoreSetupVersionFragment => _coreSetupVersionFragment.Value;
|
public string CoreSetupVersionFragment => _coreSetupVersionFragment.Value;
|
||||||
public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value;
|
public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value;
|
||||||
public string GitHubProject => _gitHubProject.Value;
|
public string GitHubProject => _gitHubProject.Value;
|
||||||
|
@ -73,5 +74,38 @@ namespace Microsoft.DotNet.Scripts
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetDefaultUpstreamBranch()
|
||||||
|
{
|
||||||
|
return GetRepoMSBuildPropValue("BranchInfo.props", "BranchName") ?? "master";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDefaultCoreSetupVersionFragment()
|
||||||
|
{
|
||||||
|
string coreSetupChannel = GetRepoMSBuildPropValue("BundledRuntimes.props", "CoreSetupChannel") ?? "master";
|
||||||
|
|
||||||
|
return $"dotnet/core-setup/{coreSetupChannel}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetRepoMSBuildPropValue(string propsFileName, string propertyName)
|
||||||
|
{
|
||||||
|
var propsFilePath = Path.Combine(Dirs.RepoRoot, "build", propsFileName);
|
||||||
|
var root = XDocument.Load(propsFilePath).Root;
|
||||||
|
var ns = root.Name.Namespace;
|
||||||
|
|
||||||
|
var value = root
|
||||||
|
.Elements(ns + "PropertyGroup")
|
||||||
|
.Elements(ns + propertyName)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.Value;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Could not find a property named '{propertyName}' in {propsFilePath}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace Microsoft.DotNet.Scripts
|
||||||
|
|
||||||
List<BuildInfo> buildInfos = new List<BuildInfo>();
|
List<BuildInfo> buildInfos = new List<BuildInfo>();
|
||||||
|
|
||||||
buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false));
|
|
||||||
buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false));
|
buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false));
|
||||||
|
|
||||||
IEnumerable<IDependencyUpdater> updaters = GetUpdaters();
|
IEnumerable<IDependencyUpdater> updaters = GetUpdaters();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue