initial spike of compile, publish and run
This commit is contained in:
parent
f40dd3d9f7
commit
ab8986e3e3
19 changed files with 3407 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>a5d41198-209a-461b-a191-f48b9dbecd67</ProjectGuid>
|
||||
<RootNamespace>DotNet.Tools.DependencyResolver</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
54
src/DotNet.Tools.DependencyResolver/Program.cs
Normal file
54
src/DotNet.Tools.DependencyResolver/Program.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
|
||||
namespace DotNet.Tools.DependencyResolver
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public void Main(string[] args)
|
||||
{
|
||||
var app = new CommandLineApplication();
|
||||
app.HelpOption("-h|--help");
|
||||
app.Description = "Resolves the absolute path of all dependencies for a project";
|
||||
|
||||
var packages = app.Option("-p|--packages <PACKAGES_DIRECTORY>", "Path to the directories containing packages to resolve.", CommandOptionType.MultipleValue);
|
||||
var target = app.Option("-t|--target <TARGET_IDENTIFIER>", "The target to resolve dependencies for.", CommandOptionType.SingleValue);
|
||||
var output = app.Option("-o|--output <OUTPUT_FILE>", "The path in which to write the output file (formatted as text with one line per dependency)", CommandOptionType.SingleValue);
|
||||
var assetType = app.Option("-a|--assets <ASSET_TYPE>", "The type of assets to resolve (common values include: compile, runtime, native)", CommandOptionType.MultipleValue);
|
||||
var project = app.Argument("PROJECT", "The project to resolve. A directory or a path to a project.lock.json may be used. Defaults to the current directory");
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
// Check required args
|
||||
if(!packages.HasValue())
|
||||
{
|
||||
Console.Error.WriteLine("Missing required argument: --packages");
|
||||
app.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
if(!target.HasValue())
|
||||
{
|
||||
Console.Error.WriteLine("Missing required argument: --target");
|
||||
app.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
if(!assetType.HasValue())
|
||||
{
|
||||
Console.Error.WriteLine("Missing required argument: --assets");
|
||||
app.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
var path = project.Value ?? Directory.GetCurrentDirectory();
|
||||
if (!path.EndsWith("project.lock.json"))
|
||||
{
|
||||
path = Path.Combine(path, "project.lock.json");
|
||||
}
|
||||
return Resolver.Execute(packages.Values, target.Value(), output.Value(), assetType.Values, path);
|
||||
});
|
||||
|
||||
app.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
84
src/DotNet.Tools.DependencyResolver/Resolver.cs
Normal file
84
src/DotNet.Tools.DependencyResolver/Resolver.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace DotNet.Tools.DependencyResolver
|
||||
{
|
||||
public static class Resolver
|
||||
{
|
||||
public static int Execute(IEnumerable<string> packageDirectories, string targetName, string output, IEnumerable<string> assetTypes, string lockFilePath)
|
||||
{
|
||||
// Open the lock file
|
||||
var lockFile = JObject.Parse(File.ReadAllText(lockFilePath));
|
||||
|
||||
// Locate the target
|
||||
var target = lockFile["targets"][targetName] as JObject;
|
||||
if (target == null)
|
||||
{
|
||||
Console.Error.WriteLine($"Could not find target in lock file: {target}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Iterate over each package and prepare the dependency data
|
||||
bool success = true;
|
||||
List<string> files = new List<string>();
|
||||
foreach (var dependency in target)
|
||||
{
|
||||
// Parse the input string
|
||||
var splat = dependency.Key.Split('/');
|
||||
var id = splat[0];
|
||||
var version = splat[1];
|
||||
|
||||
string packageRoot = null;
|
||||
foreach (var dir in packageDirectories)
|
||||
{
|
||||
var candidate = Path.Combine(dir, id, version);
|
||||
if (Directory.Exists(candidate))
|
||||
{
|
||||
packageRoot = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (packageRoot == null)
|
||||
{
|
||||
Console.Error.WriteLine($"WARNING: Unable to locate {id} {version}");
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Locate all the assets
|
||||
foreach (var assetType in assetTypes)
|
||||
{
|
||||
var assetList = dependency.Value[assetType] as JObject;
|
||||
if (assetList != null)
|
||||
{
|
||||
foreach (var asset in assetList)
|
||||
{
|
||||
var pathified = Path.Combine(asset.Key.Split('/'));
|
||||
if (!Path.GetFileName(pathified).Equals("_._", StringComparison.Ordinal))
|
||||
{
|
||||
var file = Path.Combine(packageRoot, pathified);
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
Console.Error.WriteLine($"WARNING: Missing asset: {file}");
|
||||
success = false;
|
||||
}
|
||||
files.Add(file);
|
||||
Console.WriteLine(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(output))
|
||||
{
|
||||
File.WriteAllLines(output, files);
|
||||
}
|
||||
|
||||
return success ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
24
src/DotNet.Tools.DependencyResolver/project.json
Normal file
24
src/DotNet.Tools.DependencyResolver/project.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.Console": "4.0.0-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Threading": "4.0.10-beta-*",
|
||||
"System.IO.FileSystem": "4.0.1-beta-*",
|
||||
|
||||
"Microsoft.CSharp": "4.0.0-beta-23109",
|
||||
"Microsoft.Framework.CommandLineUtils.Sources": "1.0.0-*",
|
||||
|
||||
"Newtonsoft.Json": "7.0.1"
|
||||
},
|
||||
|
||||
"commands": {
|
||||
"dotnet-resolve-dependencies": ""
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>1fe61f82-4a40-4a55-ada5-0ea1a79ac4df</ProjectGuid>
|
||||
<RootNamespace>DotNet.Tools.SourceResolver</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
31
src/DotNet.Tools.SourceResolver/Program.cs
Normal file
31
src/DotNet.Tools.SourceResolver/Program.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
|
||||
namespace DotNet.Tools.DependencyResolver
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public void Main(string[] args)
|
||||
{
|
||||
var app = new CommandLineApplication();
|
||||
app.HelpOption("-h|--help");
|
||||
app.Description = "Resolves the absolute path of all source files used by a project";
|
||||
|
||||
var output = app.Option("-o|--output <OUTPUT_FILE>", "The path in which to write the output file (formatted as text with one line per dependency)", CommandOptionType.SingleValue);
|
||||
var project = app.Argument("PROJECT", "The project to resolve. A directory or a path to a project.json may be used. Defaults to the current directory");
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
var path = project.Value ?? Directory.GetCurrentDirectory();
|
||||
if (!path.EndsWith("project.json"))
|
||||
{
|
||||
path = Path.Combine(path, "project.json");
|
||||
}
|
||||
return Resolver.Execute(path, output.Value());
|
||||
});
|
||||
|
||||
app.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
55
src/DotNet.Tools.SourceResolver/Resolver.cs
Normal file
55
src/DotNet.Tools.SourceResolver/Resolver.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Dnx.Runtime;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace DotNet.Tools.DependencyResolver
|
||||
{
|
||||
public static class Resolver
|
||||
{
|
||||
public static int Execute(string projectPath, string output)
|
||||
{
|
||||
var projectFile = new FileInfo(projectPath);
|
||||
var reader = new ProjectReader();
|
||||
var diagnostics = new List<DiagnosticMessage>();
|
||||
Project project;
|
||||
using (var stream = File.OpenRead(projectPath))
|
||||
{
|
||||
project = reader.ReadProject(
|
||||
stream,
|
||||
projectFile.Directory.Name,
|
||||
projectFile.FullName,
|
||||
diagnostics);
|
||||
}
|
||||
|
||||
foreach (var diagnostic in diagnostics)
|
||||
{
|
||||
WriteDiagnostic(diagnostic);
|
||||
}
|
||||
|
||||
if (diagnostics.HasErrors())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
foreach (var file in project.Files.SourceFiles)
|
||||
{
|
||||
Console.WriteLine(file);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(output))
|
||||
{
|
||||
File.WriteAllLines(output, project.Files.SourceFiles);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void WriteDiagnostic(DiagnosticMessage diagnostic)
|
||||
{
|
||||
Console.Error.WriteLine($"{diagnostic.Severity}: {diagnostic.FormattedMessage}");
|
||||
}
|
||||
}
|
||||
}
|
25
src/DotNet.Tools.SourceResolver/project.json
Normal file
25
src/DotNet.Tools.SourceResolver/project.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.Console": "4.0.0-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Threading": "4.0.10-beta-*",
|
||||
"System.IO.FileSystem": "4.0.1-beta-*",
|
||||
|
||||
"Microsoft.CSharp": "4.0.0-beta-23109",
|
||||
"Microsoft.Framework.CommandLineUtils.Sources": "1.0.0-*",
|
||||
"Microsoft.Dnx.Runtime": "1.0.0-*",
|
||||
|
||||
"Newtonsoft.Json": "7.0.1"
|
||||
},
|
||||
|
||||
"commands": {
|
||||
"dotnet-resolve-dependencies": ""
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue