Merge pull request #5648 from eerhardt/master-UpdateDependencies
Upgrade update-dependencies
This commit is contained in:
commit
e7689a3116
5 changed files with 45 additions and 86 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CLI_SharedFrameworkVersion>2.0.0-beta-001507-00</CLI_SharedFrameworkVersion>
|
||||
<CLI_SharedFrameworkVersion>2.0.0-beta-001509-00</CLI_SharedFrameworkVersion>
|
||||
<CLI_MSBuild_Version>15.2.0-preview-000002-01</CLI_MSBuild_Version>
|
||||
<CLI_Roslyn_Version>2.0.0-rc4-61325-08</CLI_Roslyn_Version>
|
||||
<CLI_NETSDK_Version>1.0.0-alpha-20170125-1</CLI_NETSDK_Version>
|
||||
|
|
|
@ -17,14 +17,12 @@ 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")
|
||||
/// 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")
|
||||
/// 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")
|
||||
/// 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")
|
||||
/// 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/master")
|
||||
/// GITHUB_ORIGIN_OWNER - The owner of the GitHub fork to push the commit and create the PR from. (ex. "dotnet-bot")
|
||||
/// GITHUB_UPSTREAM_OWNER - The owner of the GitHub base repo to create the PR to. (ex. "dotnet")
|
||||
/// GITHUB_PROJECT - The repo name under the ORIGIN and UPSTREAM owners. (ex. "cli")
|
||||
/// GITHUB_UPSTREAM_BRANCH - The branch in the GitHub base repo to create the PR to. (ex. "rel/1.0.0")
|
||||
/// GITHUB_UPSTREAM_BRANCH - The branch in the GitHub base repo to create the PR to. (ex. "master")
|
||||
/// GITHUB_PULL_REQUEST_NOTIFICATIONS - A semi-colon ';' separated list of GitHub users to notify on the PR.
|
||||
/// </remarks>
|
||||
public class Config
|
||||
|
@ -35,13 +33,11 @@ namespace Microsoft.DotNet.Scripts
|
|||
private Lazy<string> _email = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_EMAIL"));
|
||||
private Lazy<string> _password = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_PASSWORD"));
|
||||
|
||||
private Lazy<string> _coreFxVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("COREFX_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/corefx/release/1.0.0"));
|
||||
private Lazy<string> _coreClrVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORECLR_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/coreclr/release/1.0.0"));
|
||||
private Lazy<string> _roslynVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("ROSLYN_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/roslyn/netcore1.0"));
|
||||
private Lazy<string> _coreSetupVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/release/1.0.0"));
|
||||
private Lazy<string> _coreSetupVersionUrl = new Lazy<string>(() => GetEnvironmentVariable("CORESETUP_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info/dotnet/core-setup/master"));
|
||||
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", "rel/1.0.0"));
|
||||
private Lazy<string> _gitHubUpstreamBranch = new Lazy<string>(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "master"));
|
||||
private Lazy<string[]> _gitHubPullRequestNotifications = new Lazy<string[]>(() =>
|
||||
GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "")
|
||||
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
||||
|
@ -53,8 +49,6 @@ namespace Microsoft.DotNet.Scripts
|
|||
public string UserName => _userName.Value;
|
||||
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 GitHubUpstreamOwner => _gitHubUpstreamOwner.Value;
|
||||
|
|
|
@ -21,75 +21,57 @@ namespace Microsoft.DotNet.Scripts
|
|||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
bool onlyUpdate = args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
List<BuildInfo> buildInfos = new List<BuildInfo>();
|
||||
|
||||
buildInfos.Add(BuildInfo.Get("CoreFx", s_config.CoreFxVersionUrl, fetchLatestReleaseFile: false));
|
||||
buildInfos.Add(BuildInfo.Get("CoreClr", s_config.CoreClrVersionUrl, fetchLatestReleaseFile: false));
|
||||
buildInfos.Add(BuildInfo.Get("Roslyn", s_config.RoslynVersionUrl, fetchLatestReleaseFile: false));
|
||||
buildInfos.Add(BuildInfo.Get("CoreSetup", s_config.CoreSetupVersionUrl, fetchLatestReleaseFile: false));
|
||||
|
||||
IEnumerable<IDependencyUpdater> updaters = GetUpdaters();
|
||||
var dependencyBuildInfos = buildInfos.Select(buildInfo =>
|
||||
new DependencyBuildInfo(
|
||||
buildInfo,
|
||||
upgradeStableVersions: true,
|
||||
disabledPackages: Enumerable.Empty<string>()));
|
||||
DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos);
|
||||
|
||||
GitHubAuth gitHubAuth = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
|
||||
|
||||
DependencyUpdater dependencyUpdater = new DependencyUpdater(
|
||||
gitHubAuth,
|
||||
s_config.GitHubProject,
|
||||
s_config.GitHubUpstreamOwner,
|
||||
s_config.GitHubUpstreamBranch,
|
||||
s_config.UserName,
|
||||
s_config.GitHubPullRequestNotifications);
|
||||
|
||||
if (args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase))
|
||||
if (updateResults.ChangesDetected() && !onlyUpdate)
|
||||
{
|
||||
dependencyUpdater.Update(updaters, buildInfos);
|
||||
}
|
||||
else
|
||||
{
|
||||
dependencyUpdater.UpdateAndSubmitPullRequestAsync(updaters, buildInfos);
|
||||
GitHubAuth gitHubAuth = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
|
||||
GitHubProject origin = new GitHubProject(s_config.GitHubProject, s_config.UserName);
|
||||
GitHubBranch upstreamBranch = new GitHubBranch(
|
||||
s_config.GitHubUpstreamBranch,
|
||||
new GitHubProject(s_config.GitHubProject, s_config.GitHubUpstreamOwner));
|
||||
|
||||
string suggestedMessage = updateResults.GetSuggestedCommitMessage();
|
||||
string body = string.Empty;
|
||||
if (s_config.GitHubPullRequestNotifications.Any())
|
||||
{
|
||||
body += PullRequestCreator.NotificationString(s_config.GitHubPullRequestNotifications);
|
||||
}
|
||||
|
||||
new PullRequestCreator(gitHubAuth, origin, upstreamBranch)
|
||||
.CreateOrUpdateAsync(
|
||||
suggestedMessage,
|
||||
suggestedMessage + $" ({upstreamBranch.Name})",
|
||||
body)
|
||||
.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<IDependencyUpdater> GetUpdaters()
|
||||
{
|
||||
yield return CreateProjectJsonUpdater();
|
||||
|
||||
yield return CreateRegexUpdater(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR");
|
||||
yield return CreateRegexUpdater(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", "JitVersion", "Microsoft.NETCore.Jit");
|
||||
|
||||
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "SharedFrameworkVersion", "Microsoft.NETCore.App");
|
||||
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "HostFxrVersion", "Microsoft.NETCore.DotNetHostResolver");
|
||||
yield return CreateRegexUpdater(@"build_projects\dotnet-cli-build\CliDependencyVersions.cs", "SharedHostVersion", "Microsoft.NETCore.DotNetHost");
|
||||
yield return CreateRegexUpdater(@"build\Microsoft.DotNet.Cli.DependencyVersions.props", "CLI_SharedFrameworkVersion", "Microsoft.NETCore.App");
|
||||
}
|
||||
|
||||
private static IDependencyUpdater CreateProjectJsonUpdater()
|
||||
{
|
||||
IEnumerable<string> projectJsonFiles = GetProjectJsonsToUpdate();
|
||||
|
||||
return new ProjectJsonUpdater(projectJsonFiles)
|
||||
{
|
||||
SkipStableVersions = false
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetProjectJsonsToUpdate()
|
||||
{
|
||||
const string noUpdateFileName = ".noautoupdate";
|
||||
|
||||
return Enumerable.Union(
|
||||
Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
|
||||
Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories))
|
||||
.Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), noUpdateFileName)) &&
|
||||
!Path.GetDirectoryName(p).EndsWith("CSharp_Web", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private static IDependencyUpdater CreateRegexUpdater(string repoRelativePath, string dependencyPropertyName, string packageId)
|
||||
private static IDependencyUpdater CreateRegexUpdater(string repoRelativePath, string propertyName, string packageId)
|
||||
{
|
||||
return new FileRegexPackageUpdater()
|
||||
{
|
||||
Path = Path.Combine(Dirs.RepoRoot, repoRelativePath),
|
||||
PackageId = packageId,
|
||||
Regex = new Regex($@"{dependencyPropertyName} = ""(?<version>.*)"";"),
|
||||
Regex = new Regex($@"<{propertyName}>(?<version>.*)</{propertyName}>"),
|
||||
VersionGroupName = "version"
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<Description>Updates the repos dependencies</Description>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
<AssemblyName>update-dependencies</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64</RuntimeIdentifiers>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -14,15 +12,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.DotNet.VersionTools">
|
||||
<Version>1.0.26-prerelease-00615-07</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.DotNet.VersionTools" Version="1.0.27-prerelease-01308-02" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -18,7 +18,7 @@ if($Help)
|
|||
$Architecture='x64'
|
||||
|
||||
$RepoRoot = "$PSScriptRoot\..\.."
|
||||
$AppPath = "$PSScriptRoot"
|
||||
$ProjectPath = "$PSScriptRoot\update-dependencies.csproj"
|
||||
|
||||
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
|
||||
if (!$env:DOTNET_INSTALL_DIR)
|
||||
|
@ -28,26 +28,18 @@ if (!$env:DOTNET_INSTALL_DIR)
|
|||
|
||||
# Install a stage 0
|
||||
Write-Host "Installing .NET Core CLI Stage 0"
|
||||
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Architecture $Architecture
|
||||
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel "master" -Architecture $Architecture
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
|
||||
|
||||
# Put the stage0 on the path
|
||||
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
||||
|
||||
# Restore the app
|
||||
Write-Host "Restoring update-dependencies..."
|
||||
pushd "$AppPath"
|
||||
dotnet restore
|
||||
Write-Host "Restoring $ProjectPath..."
|
||||
dotnet restore "$ProjectPath"
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to restore" }
|
||||
popd
|
||||
|
||||
# Publish the app
|
||||
Write-Host "Compiling App..."
|
||||
dotnet publish "$AppPath" -o "$AppPath\bin" --framework netcoreapp1.0
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" }
|
||||
|
||||
# Run the app
|
||||
Write-Host "Invoking App $AppPath..."
|
||||
Write-Host " Configuration: $env:CONFIGURATION"
|
||||
& "$AppPath\bin\update-dependencies.exe"
|
||||
Write-Host "Invoking App $ProjectPath..."
|
||||
dotnet run -p "$ProjectPath"
|
||||
if($LASTEXITCODE -ne 0) { throw "Build failed" }
|
||||
|
|
Loading…
Reference in a new issue