Fix deps trimming (#107)

This commit is contained in:
Pavel Krymets 2017-05-05 13:34:58 -07:00 committed by GitHub
parent 214de568a9
commit caaae2003e
1 changed files with 10 additions and 11 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -10,6 +11,7 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Trimming main library from " +args[0]);
ChangeEntryPointLibraryName(args[0]); ChangeEntryPointLibraryName(args[0]);
} }
@ -22,7 +24,6 @@ public class Program
deps = JObject.ReadFrom(reader); deps = JObject.ReadFrom(reader);
} }
string version = null;
foreach (JProperty target in deps["targets"]) foreach (JProperty target in deps["targets"])
{ {
var targetLibrary = target.Value.Children<JProperty>().FirstOrDefault(); var targetLibrary = target.Value.Children<JProperty>().FirstOrDefault();
@ -33,16 +34,14 @@ public class Program
targetLibrary.Remove(); targetLibrary.Remove();
} }
if (version != null)
{
var library = deps["libraries"].Children<JProperty>().First();
library.Remove();
using (var file = File.CreateText(depsFile)) var library = deps["libraries"].Children<JProperty>().First();
using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) library.Remove();
{
deps.WriteTo(writer); using (var file = File.CreateText(depsFile))
} using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented })
{
deps.WriteTo(writer);
} }
} }
} }