CompileTargets moved to MSBuild

CompileTargets moved to MSBuild. Still need to work on input/outputs, refactoring of targets, specially around CompileStage and moving some of the tasks back to msbuild instead of C# code.
This commit is contained in:
Livar Cunha 2016-06-29 14:10:55 -07:00
parent 2ed5363187
commit 262a46e241
12 changed files with 492 additions and 409 deletions

View file

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Net.Http;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class RemoveAssetFromDepsPackages : Task
{
public string DepsFile { get; set; }
public string SectionName { get; set; }
public string AssetPath { get; set; }
public override bool Execute()
{
DoRemoveAssetFromDepsPackages(DepsFile, SectionName, AssetPath);
return true;
}
private static void DoRemoveAssetFromDepsPackages(string depsFile, string sectionName, string assetPath)
{
JToken deps;
using (var file = File.OpenText(depsFile))
using (JsonTextReader reader = new JsonTextReader(file))
{
deps = JObject.ReadFrom(reader);
}
foreach (JProperty target in deps["targets"])
{
foreach (JProperty pv in target.Value.Children<JProperty>())
{
var section = pv.Value[sectionName];
if (section != null)
{
foreach (JProperty relPath in section)
{
if (assetPath.Equals(relPath.Name))
{
relPath.Remove();
break;
}
}
}
}
}
using (var file = File.CreateText(depsFile))
using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented })
{
deps.WriteTo(writer);
}
}
}
}