Merge branch 'rel/1.0.0' of https://github.com/dotnet/cli into kestrel-tests2
This commit is contained in:
commit
91adaa2b8c
54 changed files with 976 additions and 198 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
@ -9,6 +10,8 @@ using static Microsoft.DotNet.Cli.Build.FS;
|
|||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
|
@ -243,6 +246,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
outputDir: Dirs.Stage1);
|
||||
|
||||
CleanOutputDir(Path.Combine(Dirs.Stage1, "sdk"));
|
||||
FS.CopyRecursive(Dirs.Stage1, Dirs.Stage1Symbols);
|
||||
|
||||
RemovePdbsFromDir(Path.Combine(Dirs.Stage1, "sdk"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -293,13 +299,23 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
|
||||
CleanOutputDir(Path.Combine(Dirs.Stage2, "sdk"));
|
||||
FS.CopyRecursive(Dirs.Stage2, Dirs.Stage2Symbols);
|
||||
|
||||
RemovePdbsFromDir(Path.Combine(Dirs.Stage2, "sdk"));
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static void CleanOutputDir(string directory)
|
||||
{
|
||||
FS.RmFilesInDirRecursive(directory, "vbc.exe");
|
||||
foreach (var file in FilesToClean)
|
||||
{
|
||||
FS.RmFilesInDirRecursive(directory, file);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemovePdbsFromDir(string directory)
|
||||
{
|
||||
FS.RmFilesInDirRecursive(directory, "*.pdb");
|
||||
}
|
||||
|
||||
|
@ -352,6 +368,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
// Rename the .deps file
|
||||
var destinationDeps = Path.Combine(SharedFrameworkNameAndVersionRoot, $"{SharedFrameworkName}.deps.json");
|
||||
File.Move(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.deps.json"), destinationDeps);
|
||||
ChangeEntryPointLibraryName(destinationDeps, null);
|
||||
|
||||
// Generate RID fallback graph
|
||||
string runtimeGraphGeneratorRuntime = null;
|
||||
|
@ -445,7 +462,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"--output",
|
||||
outputDir,
|
||||
"--framework",
|
||||
"netstandard1.5")
|
||||
"netstandard1.5")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
|
@ -468,6 +485,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"));
|
||||
File.Copy(compilersDeps, Path.Combine(outputDir, binaryToCorehostify + ".deps.json"));
|
||||
File.Copy(compilersRuntimeConfig, Path.Combine(outputDir, binaryToCorehostify + ".runtimeconfig.json"));
|
||||
ChangeEntryPointLibraryName(Path.Combine(outputDir, binaryToCorehostify + ".deps.json"), binaryToCorehostify);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -577,6 +595,42 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
private static void ChangeEntryPointLibraryName(string depsFile, string newName)
|
||||
{
|
||||
JToken deps;
|
||||
using (var file = File.OpenText(depsFile))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
deps = JObject.ReadFrom(reader);
|
||||
}
|
||||
|
||||
var target = deps["targets"][deps["runtimeTarget"]["name"].Value<string>()];
|
||||
var library = target.Children<JProperty>().First();
|
||||
var version = library.Name.Substring(library.Name.IndexOf('/') + 1);
|
||||
if (newName == null)
|
||||
{
|
||||
library.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
library.Replace(new JProperty(newName + '/' + version, library.Value));
|
||||
}
|
||||
library = deps["libraries"].Children<JProperty>().First();
|
||||
if (newName == null)
|
||||
{
|
||||
library.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
library.Replace(new JProperty(newName + '/' + version, library.Value));
|
||||
}
|
||||
using (var file = File.CreateText(depsFile))
|
||||
using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented})
|
||||
{
|
||||
deps.WriteTo(writer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeleteMainPublishOutput(string path, string name)
|
||||
{
|
||||
File.Delete(Path.Combine(path, $"{name}{Constants.ExeSuffix}"));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
@ -14,11 +15,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
private const string ENGINE = "engine.exe";
|
||||
|
||||
private const string WixVersion = "3.10.2";
|
||||
|
||||
private static string WixRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Dirs.Output, "WixTools");
|
||||
return Path.Combine(Dirs.Output, $"WixTools.{WixVersion}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,14 +57,24 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
Directory.CreateDirectory(WixRoot);
|
||||
|
||||
c.Info("Downloading WixTools..");
|
||||
// Download Wix version 3.10.2 - https://wix.codeplex.com/releases/view/619491
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
$"Invoke-WebRequest -Uri https://wix.codeplex.com/downloads/get/1540241 -Method Get -OutFile {WixRoot}\\WixTools.zip")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
DownloadFile($"https://dotnetcli.blob.core.windows.net/build/wix/wix.{WixVersion}.zip", Path.Combine(WixRoot, "WixTools.zip"));
|
||||
|
||||
c.Info("Extracting WixTools..");
|
||||
ZipFile.ExtractToDirectory($"{WixRoot}\\WixTools.zip", WixRoot);
|
||||
ZipFile.ExtractToDirectory(Path.Combine(WixRoot, "WixTools.zip"), WixRoot);
|
||||
}
|
||||
|
||||
private static void DownloadFile(string uri, string destinationPath)
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
var getTask = httpClient.GetStreamAsync(uri);
|
||||
|
||||
using (var outStream = File.OpenWrite(destinationPath))
|
||||
{
|
||||
getTask.Result.CopyTo(outStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Target]
|
||||
|
|
|
@ -175,6 +175,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
CreateZipFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkHostCompressedFile"));
|
||||
|
||||
CreateZipFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
@ -185,6 +187,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
CreateTarBallFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkSDKHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkSDKHostCompressedFile"));
|
||||
CreateTarBallFromDirectory(c.BuildContext.Get<string>("CombinedFrameworkHostRoot"), c.BuildContext.Get<string>("CombinedFrameworkHostCompressedFile"));
|
||||
|
||||
CreateTarBallFromDirectory(Path.Combine(Dirs.Stage2Symbols, "sdk"), c.BuildContext.Get<string>("SdkSymbolsCompressedFile"));
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
AddInstallerArtifactToContext(c, "dotnet-sharedframework", "SharedFramework", sharedFrameworkVersion);
|
||||
AddInstallerArtifactToContext(c, "dotnet-dev", "CombinedFrameworkSDKHost", cliVersion);
|
||||
AddInstallerArtifactToContext(c, "dotnet", "CombinedFrameworkHost", sharedFrameworkVersion);
|
||||
AddInstallerArtifactToContext(c, "dotnet-sdk-debug", "SdkSymbols", cliVersion);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
@ -205,8 +206,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
var dotnet = DotNetCli.Stage0;
|
||||
|
||||
dotnet.Restore("--verbosity", "verbose").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")).Execute().EnsureSuccessful();
|
||||
dotnet.Restore("--verbosity", "verbose", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools")).Execute().EnsureSuccessful();
|
||||
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")).Execute().EnsureSuccessful();
|
||||
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes").WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools")).Execute().EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
[Target(
|
||||
nameof(PublishTargets.PublishCombinedHostFrameworkArchiveToAzure),
|
||||
nameof(PublishTargets.PublishCombinedHostFrameworkSdkArchiveToAzure))]
|
||||
nameof(PublishTargets.PublishCombinedHostFrameworkSdkArchiveToAzure),
|
||||
nameof(PublishTargets.PublishSDKSymbolsArchiveToAzure))]
|
||||
public static BuildTargetResult PublishArchivesToAzure(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(
|
||||
|
@ -176,6 +177,17 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishSDKSymbolsArchiveToAzure(BuildTargetContext c)
|
||||
{
|
||||
var version = CliNuGetVersion;
|
||||
var archiveFile = c.BuildContext.Get<string>("SdkSymbolsCompressedFile");
|
||||
|
||||
AzurePublisherTool.PublishArchiveAndLatest(archiveFile, Channel, version);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishCombinedHostFrameworkArchiveToAzure(BuildTargetContext c)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static readonly string Packages = Path.Combine(Output, "packages");
|
||||
public static readonly string Stage1 = Path.Combine(Output, "stage1");
|
||||
public static readonly string Stage1Compilation = Path.Combine(Output, "stage1compilation");
|
||||
public static readonly string Stage1Symbols = Path.Combine(Output, "stage1symbols");
|
||||
public static readonly string Stage2 = Path.Combine(Output, "stage2");
|
||||
public static readonly string Stage2Compilation = Path.Combine(Output, "stage2compilation");
|
||||
public static readonly string Stage2Symbols = Path.Combine(Output, "stage2symbols");
|
||||
public static readonly string Corehost = Path.Combine(Output, "corehost");
|
||||
public static readonly string TestOutput = Path.Combine(Output, "tests");
|
||||
public static readonly string TestArtifacts = Path.Combine(TestOutput, "artifacts");
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
if (string.Equals(Path.GetFileName(candidate), "bin") ||
|
||||
string.Equals(Path.GetFileName(candidate), "obj"))
|
||||
{
|
||||
Directory.Delete(candidate, recursive: true);
|
||||
Utils.DeleteDirectory(candidate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -96,8 +96,24 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file);
|
||||
}
|
||||
System.Threading.Thread.Sleep(1);
|
||||
Directory.Delete(path, true);
|
||||
var retry = 5;
|
||||
while (retry >= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
return;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (retry == 0)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
System.Threading.Thread.Sleep(200);
|
||||
retry--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
30
scripts/update-dependencies/BuildContextProperties.cs
Normal file
30
scripts/update-dependencies/BuildContextProperties.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
|
||||
namespace Microsoft.DotNet.Scripts
|
||||
{
|
||||
public static class BuildContextProperties
|
||||
{
|
||||
public static List<DependencyInfo> GetDependencyInfos(this BuildTargetContext c)
|
||||
{
|
||||
const string propertyName = "DependencyInfos";
|
||||
|
||||
List<DependencyInfo> dependencyInfos;
|
||||
object dependencyInfosObj;
|
||||
if (c.BuildContext.Properties.TryGetValue(propertyName, out dependencyInfosObj))
|
||||
{
|
||||
dependencyInfos = (List<DependencyInfo>)dependencyInfosObj;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependencyInfos = new List<DependencyInfo>();
|
||||
c.BuildContext[propertyName] = dependencyInfos;
|
||||
}
|
||||
|
||||
return dependencyInfos;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ namespace Microsoft.DotNet.Scripts
|
|||
/// 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_PULL_REQUEST_NOTIFICATIONS - A semi-colon ';' separated list of GitHub users to notify on the PR.
|
||||
/// </remarks>
|
||||
public class Config
|
||||
{
|
||||
|
@ -36,6 +37,7 @@ namespace Microsoft.DotNet.Scripts
|
|||
public string GitHubUpstreamOwner { get; set; }
|
||||
public string GitHubProject { get; set; }
|
||||
public string GitHubUpstreamBranch { get; set; }
|
||||
public string[] GitHubPullRequestNotifications { get; set; }
|
||||
|
||||
private static Config Read()
|
||||
{
|
||||
|
@ -52,18 +54,20 @@ namespace Microsoft.DotNet.Scripts
|
|||
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)
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetEnvironmentVariable(string name, string defaultValue = null)
|
||||
{
|
||||
string value = Environment.GetEnvironmentVariable(name);
|
||||
if (string.IsNullOrEmpty(value))
|
||||
if (value == null)
|
||||
{
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
if (value == null)
|
||||
{
|
||||
throw new BuildFailureException($"Can't find environment variable '{name}'.");
|
||||
}
|
||||
|
|
15
scripts/update-dependencies/DependencyInfo.cs
Normal file
15
scripts/update-dependencies/DependencyInfo.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.Scripts
|
||||
{
|
||||
public class DependencyInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string IdPattern { get; set; }
|
||||
public string IdExclusionPattern { get; set; }
|
||||
public string NewReleaseVersion { get; set; }
|
||||
|
||||
public bool IsUpdated { get; set; }
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Octokit;
|
||||
|
||||
|
@ -14,8 +15,6 @@ namespace Microsoft.DotNet.Scripts
|
|||
/// </summary>
|
||||
public static class PushPRTargets
|
||||
{
|
||||
private const string PullRequestTitle = "Updating dependencies from last known good builds";
|
||||
|
||||
private static readonly Config s_config = Config.Instance;
|
||||
|
||||
[Target(nameof(CommitChanges), nameof(CreatePR))]
|
||||
|
@ -28,14 +27,31 @@ namespace Microsoft.DotNet.Scripts
|
|||
[Target]
|
||||
public static BuildTargetResult CommitChanges(BuildTargetContext c)
|
||||
{
|
||||
Cmd("git", "add", ".")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
CommandResult statusResult = Cmd("git", "status", "--porcelain")
|
||||
.CaptureStdOut()
|
||||
.Execute();
|
||||
statusResult.EnsureSuccessful();
|
||||
|
||||
bool hasModifiedFiles = !string.IsNullOrWhiteSpace(statusResult.StdOut);
|
||||
bool hasUpdatedDependencies = c.GetDependencyInfos().Where(d => d.IsUpdated).Any();
|
||||
|
||||
if (hasModifiedFiles != hasUpdatedDependencies)
|
||||
{
|
||||
return c.Failed($"'git status' does not match DependencyInfo information. Git has modified files: {hasModifiedFiles}. DependencyInfo is updated: {hasUpdatedDependencies}.");
|
||||
}
|
||||
|
||||
if (!hasUpdatedDependencies)
|
||||
{
|
||||
c.Warn("Dependencies are currently up to date");
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
string userName = s_config.UserName;
|
||||
string email = s_config.Email;
|
||||
|
||||
Cmd("git", "commit", "-m", PullRequestTitle, "--author", $"{userName} <{email}>")
|
||||
string commitMessage = GetCommitMessage(c);
|
||||
|
||||
Cmd("git", "commit", "-a", "-m", commitMessage, "--author", $"{userName} <{email}>")
|
||||
.EnvironmentVariable("GIT_COMMITTER_NAME", userName)
|
||||
.EnvironmentVariable("GIT_COMMITTER_EMAIL", email)
|
||||
.Execute()
|
||||
|
@ -79,12 +95,19 @@ namespace Microsoft.DotNet.Scripts
|
|||
public static BuildTargetResult CreatePR(BuildTargetContext c)
|
||||
{
|
||||
string remoteBranchName = c.GetRemoteBranchName();
|
||||
string commitMessage = c.GetCommitMessage();
|
||||
|
||||
NewPullRequest prInfo = new NewPullRequest(
|
||||
PullRequestTitle,
|
||||
commitMessage,
|
||||
s_config.GitHubOriginOwner + ":" + remoteBranchName,
|
||||
s_config.GitHubUpstreamBranch);
|
||||
|
||||
string[] prNotifications = s_config.GitHubPullRequestNotifications;
|
||||
if (prNotifications.Length > 0)
|
||||
{
|
||||
prInfo.Body = $"/cc @{string.Join(" @", prNotifications)}";
|
||||
}
|
||||
|
||||
GitHubClient gitHub = new GitHubClient(new ProductHeaderValue("dotnetDependencyUpdater"));
|
||||
|
||||
gitHub.Credentials = new Credentials(s_config.Password);
|
||||
|
@ -104,5 +127,36 @@ namespace Microsoft.DotNet.Scripts
|
|||
{
|
||||
c.BuildContext["RemoteBranchName"] = value;
|
||||
}
|
||||
|
||||
private static string GetCommitMessage(this BuildTargetContext c)
|
||||
{
|
||||
const string commitMessagePropertyName = "CommitMessage";
|
||||
|
||||
string message;
|
||||
object messageObject;
|
||||
if (c.BuildContext.Properties.TryGetValue(commitMessagePropertyName, out messageObject))
|
||||
{
|
||||
message = (string)messageObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
DependencyInfo[] updatedDependencies = c.GetDependencyInfos()
|
||||
.Where(d => d.IsUpdated)
|
||||
.ToArray();
|
||||
|
||||
string updatedDependencyNames = string.Join(", ", updatedDependencies.Select(d => d.Name));
|
||||
string updatedDependencyVersions = string.Join(", ", updatedDependencies.Select(d => d.NewReleaseVersion));
|
||||
|
||||
message = $"Updating {updatedDependencyNames} to {updatedDependencyVersions}";
|
||||
if (updatedDependencies.Count() > 1)
|
||||
{
|
||||
message += " respectively";
|
||||
}
|
||||
|
||||
c.BuildContext[commitMessagePropertyName] = message;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Microsoft.DotNet.Scripts
|
|||
const string coreFxIdPattern = @"^(?i)((System\..*)|(NETStandard\.Library)|(Microsoft\.CSharp)|(Microsoft\.NETCore.*)|(Microsoft\.TargetingPack\.Private\.(CoreCLR|NETNative))|(Microsoft\.Win32\..*)|(Microsoft\.VisualBasic))$";
|
||||
const string coreFxIdExclusionPattern = @"System.CommandLine";
|
||||
|
||||
List<DependencyInfo> dependencyInfos = c.GetDependencyInfo();
|
||||
List<DependencyInfo> dependencyInfos = c.GetDependencyInfos();
|
||||
dependencyInfos.Add(new DependencyInfo()
|
||||
{
|
||||
Name = "CoreFx",
|
||||
|
@ -46,26 +46,7 @@ namespace Microsoft.DotNet.Scripts
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
private static List<DependencyInfo> GetDependencyInfo(this BuildTargetContext c)
|
||||
{
|
||||
const string propertyName = "DependencyInfo";
|
||||
|
||||
List<DependencyInfo> dependencyInfos;
|
||||
object dependencyInfosObj;
|
||||
if (c.BuildContext.Properties.TryGetValue(propertyName, out dependencyInfosObj))
|
||||
{
|
||||
dependencyInfos = (List<DependencyInfo>)dependencyInfosObj;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependencyInfos = new List<DependencyInfo>();
|
||||
c.BuildContext[propertyName] = dependencyInfos;
|
||||
}
|
||||
|
||||
return dependencyInfos;
|
||||
}
|
||||
|
||||
[Target(nameof(ReplaceProjectJson), nameof(ReplaceCrossGen))]
|
||||
[Target(nameof(ReplaceProjectJson), nameof(ReplaceCrossGen), nameof(ReplaceCoreHostPackaging))]
|
||||
public static BuildTargetResult ReplaceVersions(BuildTargetContext c) => c.Success();
|
||||
|
||||
/// <summary>
|
||||
|
@ -74,7 +55,7 @@ namespace Microsoft.DotNet.Scripts
|
|||
[Target]
|
||||
public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c)
|
||||
{
|
||||
List<DependencyInfo> dependencyInfos = c.GetDependencyInfo();
|
||||
List<DependencyInfo> dependencyInfos = c.GetDependencyInfos();
|
||||
|
||||
IEnumerable<string> projectJsonFiles = Enumerable.Union(
|
||||
Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
|
||||
|
@ -157,6 +138,9 @@ namespace Microsoft.DotNet.Scripts
|
|||
dependencyProperty.Value = newVersion;
|
||||
}
|
||||
|
||||
// mark the DependencyInfo as updated so we can tell which dependencies were updated
|
||||
dependencyInfo.IsUpdated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -194,40 +178,68 @@ namespace Microsoft.DotNet.Scripts
|
|||
.SelectMany(o => o.Children<JProperty>());
|
||||
}
|
||||
|
||||
private class DependencyInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string IdPattern { get; set; }
|
||||
public string IdExclusionPattern { get; set; }
|
||||
public string NewReleaseVersion { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces version number that is hard-coded in the CrossGen script.
|
||||
/// </summary>
|
||||
[Target]
|
||||
public static BuildTargetResult ReplaceCrossGen(BuildTargetContext c)
|
||||
{
|
||||
DependencyInfo coreFXInfo = c.GetDependencyInfo().Single(d => d.Name == "CoreFx");
|
||||
|
||||
string compileTargetsPath = Path.Combine(Dirs.RepoRoot, @"scripts\dotnet-cli-build\CompileTargets.cs");
|
||||
string compileTargetsContent = File.ReadAllText(compileTargetsPath);
|
||||
|
||||
Regex regex = new Regex(@"CoreCLRVersion = ""(?<version>\d.\d.\d)-(?<release>.*)"";");
|
||||
compileTargetsContent = regex.Replace(compileTargetsContent, m =>
|
||||
ReplaceFileContents(@"scripts\dotnet-cli-build\CompileTargets.cs", compileTargetsContent =>
|
||||
{
|
||||
string replacedValue = m.Value;
|
||||
Group releaseGroup = m.Groups["release"];
|
||||
DependencyInfo coreFXInfo = c.GetCoreFXDependency();
|
||||
Regex regex = new Regex(@"CoreCLRVersion = ""(?<version>\d.\d.\d)-(?<release>.*)"";");
|
||||
|
||||
replacedValue = replacedValue.Remove(releaseGroup.Index - m.Index, releaseGroup.Length);
|
||||
replacedValue = replacedValue.Insert(releaseGroup.Index - m.Index, coreFXInfo.NewReleaseVersion);
|
||||
|
||||
return replacedValue;
|
||||
return regex.ReplaceGroupValue(compileTargetsContent, "release", coreFXInfo.NewReleaseVersion);
|
||||
});
|
||||
|
||||
File.WriteAllText(compileTargetsPath, compileTargetsContent, Encoding.UTF8);
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces version number that is hard-coded in the corehost packaging dir.props file.
|
||||
/// </summary>
|
||||
[Target]
|
||||
public static BuildTargetResult ReplaceCoreHostPackaging(BuildTargetContext c)
|
||||
{
|
||||
ReplaceFileContents(@"src\corehost\packaging\dir.props", contents =>
|
||||
{
|
||||
DependencyInfo coreFXInfo = c.GetCoreFXDependency();
|
||||
Regex regex = new Regex(@"Microsoft\.NETCore\.Platforms\\(?<version>\d\.\d\.\d)-(?<release>.*)\\runtime\.json");
|
||||
|
||||
return regex.ReplaceGroupValue(contents, "release", coreFXInfo.NewReleaseVersion);
|
||||
});
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static DependencyInfo GetCoreFXDependency(this BuildTargetContext c)
|
||||
{
|
||||
return c.GetDependencyInfos().Single(d => d.Name == "CoreFx");
|
||||
}
|
||||
|
||||
private static void ReplaceFileContents(string repoRelativePath, Func<string, string> replacement)
|
||||
{
|
||||
string fullPath = Path.Combine(Dirs.RepoRoot, repoRelativePath);
|
||||
string contents = File.ReadAllText(fullPath);
|
||||
|
||||
contents = replacement(contents);
|
||||
|
||||
File.WriteAllText(fullPath, contents, Encoding.UTF8);
|
||||
}
|
||||
|
||||
private static string ReplaceGroupValue(this Regex regex, string input, string groupName, string newValue)
|
||||
{
|
||||
return regex.Replace(input, m =>
|
||||
{
|
||||
string replacedValue = m.Value;
|
||||
Group group = m.Groups[groupName];
|
||||
int startIndex = group.Index - m.Index;
|
||||
|
||||
replacedValue = replacedValue.Remove(startIndex, group.Length);
|
||||
replacedValue = replacedValue.Insert(startIndex, newValue);
|
||||
|
||||
return replacedValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"Microsoft.CSharp": "4.0.1-rc2-23931",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-23931",
|
||||
"Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*",
|
||||
"NuGet.Versioning": "3.5.0-beta-1123",
|
||||
"NuGet.Versioning": "3.5.0-beta-1130",
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Octokit": "0.18.0",
|
||||
"Microsoft.Net.Http": "2.2.29"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue