Do not trim refs

This commit is contained in:
Pavel Krymets 2016-04-01 21:52:08 -07:00
parent f665c28173
commit 8831bb4a8b
31 changed files with 455 additions and 108 deletions

View file

@ -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
{
@ -352,6 +355,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 +449,7 @@ namespace Microsoft.DotNet.Cli.Build
"--output",
outputDir,
"--framework",
"netstandard1.5")
"netstandard1.5")
.Execute()
.EnsureSuccessful();
@ -468,6 +472,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 +582,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}"));

View file

@ -205,8 +205,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();
}

View file

@ -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
{

View file

@ -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--;
}
}
}
}