5ebc6a1ceb
* Eliminate CleanPublishOutput * Decompose Crossgen Task * WiP * TarGzFileExtractToDirectory * FixModeFlags --> CHMod Also various eliminations of dead code * Tasks cleanup Move all tasks to .tasks file. There is little value in keepint them in each source file as they are already being used assumptively by files that happen to get executed later. Also eliminating uses of <Exec> for DotNet invocations * Move to BuildTools implementation of TarGzCreateFromDirectory * Eliminate Command.cs and helpers * Remove dead code * Revert TarGz from BuildTools Latest build tools package has not picked up the task, though it is checked in. * Disable ChMod on Windows * Windows bug fix * PR Feedback * Finish changing Chmod caps
60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using Microsoft.DotNet.Cli.Build.Framework;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
{
|
|
public class PublishMutationUtilties
|
|
{
|
|
public 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);
|
|
}
|
|
|
|
string version = null;
|
|
foreach (JProperty target in deps["targets"])
|
|
{
|
|
var targetLibrary = target.Value.Children<JProperty>().FirstOrDefault();
|
|
if (targetLibrary == null)
|
|
{
|
|
continue;
|
|
}
|
|
version = targetLibrary.Name.Substring(targetLibrary.Name.IndexOf('/') + 1);
|
|
if (newName == null)
|
|
{
|
|
targetLibrary.Remove();
|
|
}
|
|
else
|
|
{
|
|
targetLibrary.Replace(new JProperty(newName + '/' + version, targetLibrary.Value));
|
|
}
|
|
}
|
|
if (version != null)
|
|
{
|
|
var 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|