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
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
###############################################################################
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior for command prompt diff.
|
||||||
|
#
|
||||||
|
# This is need for earlier builds of msysgit that does not have it on by
|
||||||
|
# default for csharp files.
|
||||||
|
# Note: This is only used by command line
|
||||||
|
###############################################################################
|
||||||
|
#*.cs diff=csharp
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set the merge driver for project and solution files
|
||||||
|
#
|
||||||
|
# Merging from the command prompt will add diff markers to the files if there
|
||||||
|
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||||
|
# the diff markers are never inserted). Diff markers may cause the following
|
||||||
|
# file extensions to fail to load in VS. An alternative would be to treat
|
||||||
|
# these files as binary and thus will always conflict and require user
|
||||||
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
|
###############################################################################
|
||||||
|
#*.sln merge=binary
|
||||||
|
#*.csproj merge=binary
|
||||||
|
#*.vbproj merge=binary
|
||||||
|
#*.vcxproj merge=binary
|
||||||
|
#*.vcproj merge=binary
|
||||||
|
#*.dbproj merge=binary
|
||||||
|
#*.fsproj merge=binary
|
||||||
|
#*.lsproj merge=binary
|
||||||
|
#*.wixproj merge=binary
|
||||||
|
#*.modelproj merge=binary
|
||||||
|
#*.sqlproj merge=binary
|
||||||
|
#*.wwaproj merge=binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# behavior for image files
|
||||||
|
#
|
||||||
|
# image files are treated as binary by default.
|
||||||
|
###############################################################################
|
||||||
|
#*.jpg binary
|
||||||
|
#*.png binary
|
||||||
|
#*.gif binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# diff behavior for common document formats
|
||||||
|
#
|
||||||
|
# Convert binary document formats to text before diffing them. This feature
|
||||||
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
|
# entries below.
|
||||||
|
###############################################################################
|
||||||
|
#*.doc diff=astextplain
|
||||||
|
#*.DOC diff=astextplain
|
||||||
|
#*.docx diff=astextplain
|
||||||
|
#*.DOCX diff=astextplain
|
||||||
|
#*.dot diff=astextplain
|
||||||
|
#*.DOT diff=astextplain
|
||||||
|
#*.pdf diff=astextplain
|
||||||
|
#*.PDF diff=astextplain
|
||||||
|
#*.rtf diff=astextplain
|
||||||
|
#*.RTF diff=astextplain
|
10
NuGet.Config
Normal file
10
NuGet.Config
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||||
|
<clear />
|
||||||
|
<add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
||||||
|
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||||
|
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
44
dotnet-cli.sln
Normal file
44
dotnet-cli.sln
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.23107.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1F391100-F011-4630-8C25-D1A5355E4F19}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5AB144A3-3D0A-4DC7-9EE8-19FDD2DF8735}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
dotnet-compile.cmd = dotnet-compile.cmd
|
||||||
|
dotnet-run.cmd = dotnet-run.cmd
|
||||||
|
global.json = global.json
|
||||||
|
NuGet.Config = NuGet.Config
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{47858134-8A8D-4D5C-ABD5-E6630A66DA05}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "test\TestApp\TestApp.xproj", "{58808BBC-371E-47D6-A3D0-4902145EDA4E}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DotNet.Tools.DependencyResolver", "src\DotNet.Tools.DependencyResolver\DotNet.Tools.DependencyResolver.xproj", "{A5D41198-209A-461B-A191-F48B9DBECD67}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A5D41198-209A-461B-A191-F48B9DBECD67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A5D41198-209A-461B-A191-F48B9DBECD67}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A5D41198-209A-461B-A191-F48B9DBECD67}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A5D41198-209A-461B-A191-F48B9DBECD67}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{58808BBC-371E-47D6-A3D0-4902145EDA4E} = {47858134-8A8D-4D5C-ABD5-E6630A66DA05}
|
||||||
|
{A5D41198-209A-461B-A191-F48B9DBECD67} = {1F391100-F011-4630-8C25-D1A5355E4F19}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
30
dotnet-compile.ps1
Normal file
30
dotnet-compile.ps1
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
$OutputName = Split-Path -Leaf (Get-Location)
|
||||||
|
$OutputPath = Join-Path (Get-Location) "bin"
|
||||||
|
|
||||||
|
if(!(Test-Path $OutputPath)) {
|
||||||
|
mkdir $OutputPath | Out-Null
|
||||||
|
}
|
||||||
|
$OutputPath = (Convert-Path $OutputPath)
|
||||||
|
|
||||||
|
|
||||||
|
# Resolve compilation dependencies
|
||||||
|
Write-Host "Resolving dependencies..."
|
||||||
|
$refs = dnx -p "$PSScriptRoot\src\DotNet.Tools.DependencyResolver" run --packages "$env:USERPROFILE\.dnx\packages" --target "DNXCore,Version=v5.0" --assets compile
|
||||||
|
|
||||||
|
# Resolve source files
|
||||||
|
Write-Host "Finding source files..."
|
||||||
|
$srcs = dnx -p "$PSScriptRoot\src\DotNet.Tools.SourceResolver" run
|
||||||
|
|
||||||
|
# Build csc response file
|
||||||
|
$resp = @($refs | foreach { "/r:$_" })
|
||||||
|
$resp += @($srcs | foreach { $_ })
|
||||||
|
$resp += @(
|
||||||
|
"/out:$OutputPath\$OutputName.dll"
|
||||||
|
"/nostdlib"
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Compiling..."
|
||||||
|
$resp > "$OutputPath\csc.rsp"
|
||||||
|
csc "@$OutputPath\csc.rsp"
|
||||||
|
|
||||||
|
Write-Host " $OutputName -> $OutputPath\$OutputName.dll"
|
31
dotnet-publish.ps1
Normal file
31
dotnet-publish.ps1
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
$OutputName = Split-Path -Leaf (Get-Location)
|
||||||
|
$OutputPath = Join-Path (Join-Path (Get-Location) "bin") "publish"
|
||||||
|
|
||||||
|
& $PSScriptRoot\dotnet-compile.ps1
|
||||||
|
|
||||||
|
if(Test-Path $OutputPath) {
|
||||||
|
del -Recurse -Force $OutputPath
|
||||||
|
}
|
||||||
|
mkdir $OutputPath | Out-Null
|
||||||
|
$OutputPath = (Convert-Path $OutputPath)
|
||||||
|
|
||||||
|
# Resolve runtime and native dependencies
|
||||||
|
Write-Host "Resolving dependencies..."
|
||||||
|
$refs = dnx -p "$PSScriptRoot\src\DotNet.Tools.DependencyResolver" run --packages "$env:USERPROFILE\.dnx\packages" --target "DNXCore,Version=v5.0/win7-x64" --assets runtime --assets native
|
||||||
|
|
||||||
|
# Copy everything to one directory
|
||||||
|
$refs | foreach {
|
||||||
|
Write-Host "Publishing $_ ..."
|
||||||
|
cp $_ $OutputPath
|
||||||
|
}
|
||||||
|
|
||||||
|
$ProjectBinary = (Join-Path (Get-Location) "bin\$OutputName.dll")
|
||||||
|
Write-Host "Publishing $ProjectBinary ..."
|
||||||
|
cp $ProjectBinary $OutputPath
|
||||||
|
|
||||||
|
# CoreConsole should have come along for the ride
|
||||||
|
$CoreConsolePath = Join-Path $OutputPath "CoreConsole.exe"
|
||||||
|
if(!(Test-Path $CoreConsolePath)) {
|
||||||
|
throw "Unable to locate CoreConsole.exe. You must have a dependency on Microsoft.NETCore.ConsoleHost (for now ;))"
|
||||||
|
}
|
||||||
|
mv $CoreConsolePath (Join-Path $OutputPath "$OutputName.exe")
|
6
dotnet-run.ps1
Normal file
6
dotnet-run.ps1
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
$OutputName = Split-Path -Leaf (Get-Location)
|
||||||
|
|
||||||
|
& $PSScriptRoot\dotnet-compile.ps1
|
||||||
|
|
||||||
|
# Still need to use DNX, but it just boots CoreCLR, no runtime involved.
|
||||||
|
dnx run bin\$OutputName.exe
|
3
global.json
Normal file
3
global.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"projects": [ "src", "test" ]
|
||||||
|
}
|
|
@ -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": { }
|
||||||
|
}
|
||||||
|
}
|
12
test/TestApp/Program.cs
Normal file
12
test/TestApp/Program.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("This is a test app");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
test/TestApp/TestApp.xproj
Normal file
20
test/TestApp/TestApp.xproj
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?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>58808bbc-371e-47d6-a3d0-4902145eda4e</ProjectGuid>
|
||||||
|
<RootNamespace>TestApp</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>
|
13
test/TestApp/project.json
Normal file
13
test/TestApp/project.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.ConsoleHost": "1.0.0-*",
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.0-*",
|
||||||
|
"System.Console": "4.0.0-beta-23109"
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"dnxcore50": { }
|
||||||
|
}
|
||||||
|
}
|
2865
test/TestApp/project.lock.json
Normal file
2865
test/TestApp/project.lock.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue