dotnet-run command
This commit is contained in:
parent
cfb5a1836e
commit
3ce7a84a04
12 changed files with 386 additions and 15 deletions
|
@ -66,6 +66,7 @@ dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --config
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
||||||
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
|
||||||
|
|
||||||
# Deploy CLR host to the output
|
# Deploy CLR host to the output
|
||||||
cp "$HOST_DIR/corehost" "$STAGE1_DIR"
|
cp "$HOST_DIR/corehost" "$STAGE1_DIR"
|
||||||
|
@ -82,6 +83,7 @@ dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --config
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
||||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
||||||
|
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
|
||||||
|
|
||||||
# Deploy CLR host to the output
|
# Deploy CLR host to the output
|
||||||
cp "$HOST_DIR/corehost" "$STAGE2_DIR"
|
cp "$HOST_DIR/corehost" "$STAGE2_DIR"
|
||||||
|
|
|
@ -156,6 +156,12 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
_stdErrCapture?.GetStringBuilder()?.ToString());
|
_stdErrCapture?.GetStringBuilder()?.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Command EnvironmentVariable(string name, string value)
|
||||||
|
{
|
||||||
|
_process.StartInfo.Environment.Add(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Command CaptureStdOut()
|
public Command CaptureStdOut()
|
||||||
{
|
{
|
||||||
ThrowIfRunning();
|
ThrowIfRunning();
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"commands": {
|
|
||||||
"dotnet": "Microsoft.DotNet.Cli"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"commands": {
|
|
||||||
"dotnet-compile-csc": "Microsoft.DotNet.Tools.Compiler.Csc"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"commands": {
|
|
||||||
"dotnet-compile": "Microsoft.DotNet.Tools.Compiler"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"commands": {
|
|
||||||
"dotnet-publish": "Microsoft.DotNet.Tools.Publish"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"commands": {
|
|
||||||
"resgen": "Microsoft.DotNet.Tools.Resgen"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
"System.Console": "4.0.0-beta-23428",
|
"System.Console": "4.0.0-beta-23428",
|
||||||
|
|
|
@ -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>0a309227-a9d8-4ddf-88dd-326b57b04378</ProjectGuid>
|
||||||
|
<RootNamespace>Microsoft.DotNet.Tools.Compiler</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>
|
101
src/Microsoft.DotNet.Tools.Run/Program.cs
Normal file
101
src/Microsoft.DotNet.Tools.Run/Program.cs
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.DotNet.Tools.Common;
|
||||||
|
using Microsoft.Extensions.ProjectModel;
|
||||||
|
using Microsoft.Extensions.ProjectModel.Compilation;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools.Compiler
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
DebugHelper.HandleDebugSwitch(ref args);
|
||||||
|
|
||||||
|
var app = new CommandLineApplication(throwOnUnexpectedArg: false);
|
||||||
|
app.Name = "dotnet run";
|
||||||
|
app.FullName = ".NET Executor";
|
||||||
|
app.Description = "Runner for the .NET Platform";
|
||||||
|
app.HelpOption("-h|--help");
|
||||||
|
|
||||||
|
var framework = app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||||
|
var configuration = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||||
|
var preserveTemporaryOutput = app.Option("-p|--preserve-temporary", "Configuration under which to build", CommandOptionType.NoValue);
|
||||||
|
var project = app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");
|
||||||
|
|
||||||
|
app.OnExecute(() =>
|
||||||
|
{
|
||||||
|
// Locate the project and get the name and full path
|
||||||
|
var path = project.Value;
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
path = Directory.GetCurrentDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
var contexts = ProjectContext.CreateContextForEachFramework(path);
|
||||||
|
if (!framework.HasValue())
|
||||||
|
{
|
||||||
|
return Run(contexts.First(), configuration.Value() ?? Constants.DefaultConfiguration, app.RemainingArguments, preserveTemporaryOutput.HasValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var context = contexts.FirstOrDefault(c => c.TargetFramework.Equals(NuGetFramework.Parse(framework.Value())));
|
||||||
|
return Run(context, configuration.Value() ?? Constants.DefaultConfiguration, app.RemainingArguments, preserveTemporaryOutput.HasValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return app.Execute(args);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.Error.WriteLine(ex);
|
||||||
|
#else
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Run(ProjectContext context, string configuration, IEnumerable<string> remainingArguments, bool preserveTemporaryOutput)
|
||||||
|
{
|
||||||
|
// Create a temporary directory
|
||||||
|
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
|
||||||
|
|
||||||
|
// Compile to that directory
|
||||||
|
var result = Command.Create($"dotnet-compile", $"--output \"{tempDir}\" --framework \"{context.TargetFramework}\" --configuration \"{configuration}\"")
|
||||||
|
.ForwardStdOut()
|
||||||
|
.ForwardStdErr()
|
||||||
|
.Execute();
|
||||||
|
if (result.ExitCode != 0)
|
||||||
|
{
|
||||||
|
Reporter.Error.WriteLine($"Failed to compile {context.RootProject.Identity.Name}".Red().Bold());
|
||||||
|
return result.ExitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now launch the output and give it the results
|
||||||
|
var outputName = Path.Combine(tempDir, context.ProjectFile.Name + Constants.ExeSuffix);
|
||||||
|
result = Command.Create(outputName, string.Join(" ", remainingArguments))
|
||||||
|
.ForwardStdOut()
|
||||||
|
.ForwardStdErr()
|
||||||
|
.EnvironmentVariable("CLRHOST_CLR_PATH", AppContext.BaseDirectory)
|
||||||
|
.Execute();
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
if (!preserveTemporaryOutput)
|
||||||
|
{
|
||||||
|
Directory.Delete(tempDir, recursive: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ExitCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,196 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools.Compiler
|
||||||
|
{
|
||||||
|
internal static class CreateCSharpManifestResourceName
|
||||||
|
{
|
||||||
|
// Original source: https://raw.githubusercontent.com/Microsoft/msbuild/82177a50da735cc0443ac10fa490d69368403d71/src/XMakeTasks/CreateCSharpManifestResourceName.cs
|
||||||
|
|
||||||
|
public static string CreateManifestName(string fileName, string rootNamespace)
|
||||||
|
{
|
||||||
|
var name = new StringBuilder();
|
||||||
|
|
||||||
|
// Differences from the msbuild task:
|
||||||
|
// - we do not include the name of the first class (if any) for binary resources or source code
|
||||||
|
// - culture info is ignored
|
||||||
|
|
||||||
|
if (rootNamespace != null && rootNamespace.Length > 0)
|
||||||
|
{
|
||||||
|
name.Append(rootNamespace).Append(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace spaces in the directory name with underscores.
|
||||||
|
// Note that spaces in the file name itself are preserved.
|
||||||
|
var path = MakeValidIdentifier(Path.GetDirectoryName(fileName));
|
||||||
|
|
||||||
|
// This is different from the msbuild task: we always append extensions because otherwise,
|
||||||
|
// the emitted resource doesn't have an extension and it is not the same as in the classic
|
||||||
|
// C# assembly
|
||||||
|
if (ResourcePathUtility.IsResxResourceFile(fileName))
|
||||||
|
{
|
||||||
|
name.Append(Path.Combine(path, Path.GetFileNameWithoutExtension(fileName)));
|
||||||
|
name.Append(".resources");
|
||||||
|
name.Replace(Path.DirectorySeparatorChar, '.');
|
||||||
|
name.Replace(Path.AltDirectorySeparatorChar, '.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name.Append(Path.Combine(path, Path.GetFileName(fileName)));
|
||||||
|
name.Replace(Path.DirectorySeparatorChar, '.');
|
||||||
|
name.Replace(Path.AltDirectorySeparatorChar, '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return name.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The code below the same is same as here: https://raw.githubusercontent.com/Microsoft/msbuild/41b137cd8805079af7792995e044521d62fcb005/src/XMakeTasks/CreateManifestResourceName.cs
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is provided for compatibility with MsBuild which used to convert parts of resource names into
|
||||||
|
/// valid identifiers
|
||||||
|
/// </summary>
|
||||||
|
private static string MakeValidIdentifier(string name)
|
||||||
|
{
|
||||||
|
var id = new StringBuilder(name.Length);
|
||||||
|
|
||||||
|
// split the name into folder names
|
||||||
|
var subNames = name.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
|
||||||
|
|
||||||
|
// convert every folder name
|
||||||
|
id.Append(MakeValidFolderIdentifier(subNames[0]));
|
||||||
|
|
||||||
|
for (int i = 1; i < subNames.Length; i++)
|
||||||
|
{
|
||||||
|
id.Append('.');
|
||||||
|
id.Append(MakeValidFolderIdentifier(subNames[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return id.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make a folder name into an identifier
|
||||||
|
/// </summary>
|
||||||
|
private static string MakeValidFolderIdentifier(string name)
|
||||||
|
{
|
||||||
|
// give string length to avoid reallocations; +1 since the resulting string may be one char longer than the
|
||||||
|
// original - if the name is a single underscore we add another underscore to it
|
||||||
|
var id = new StringBuilder(name.Length + 1);
|
||||||
|
|
||||||
|
// split folder name into subnames separated by '.', if any
|
||||||
|
var subNames = name.Split(new char[] { '.' });
|
||||||
|
|
||||||
|
// convert each subname separately
|
||||||
|
id.Append(MakeValidSubFolderIdentifier(subNames[0]));
|
||||||
|
|
||||||
|
for (int i = 1; i < subNames.Length; i++)
|
||||||
|
{
|
||||||
|
id.Append('.');
|
||||||
|
id.Append(MakeValidSubFolderIdentifier(subNames[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// folder name cannot be a single underscore - add another underscore to it
|
||||||
|
if (id.ToString() == "_")
|
||||||
|
{
|
||||||
|
id.Append('_');
|
||||||
|
}
|
||||||
|
|
||||||
|
return id.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Make a folder subname into identifier
|
||||||
|
/// </summary>
|
||||||
|
private static string MakeValidSubFolderIdentifier(string subName)
|
||||||
|
{
|
||||||
|
if (subName.Length == 0)
|
||||||
|
{
|
||||||
|
return subName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// give string length to avoid reallocations; +1 since the resulting string may be one char longer than the
|
||||||
|
// original - if the first character is an invalid first identifier character but a valid subsequent one,
|
||||||
|
// we prepend an underscore to it.
|
||||||
|
var id = new StringBuilder(subName.Length + 1);
|
||||||
|
|
||||||
|
// the first character has stronger restrictions than the rest
|
||||||
|
if (!IsValidIdFirstChar(subName[0]))
|
||||||
|
{
|
||||||
|
// if the first character is not even a valid subsequent character, replace it with an underscore
|
||||||
|
if (!IsValidIdChar(subName[0]))
|
||||||
|
{
|
||||||
|
id.Append('_');
|
||||||
|
}
|
||||||
|
// if it is a valid subsequent character, prepend an underscore to it
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id.Append('_');
|
||||||
|
id.Append(subName[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id.Append(subName[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// process the rest of the subname
|
||||||
|
for (int i = 1; i < subName.Length; i++)
|
||||||
|
{
|
||||||
|
if (!IsValidIdChar(subName[i]))
|
||||||
|
{
|
||||||
|
id.Append('_');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id.Append(subName[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return id.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is the character a valid first identifier character?
|
||||||
|
/// </summary>
|
||||||
|
private static bool IsValidIdFirstChar(char c)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
char.IsLetter(c) ||
|
||||||
|
CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.ConnectorPunctuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is the character a valid identifier character?
|
||||||
|
/// </summary>
|
||||||
|
private static bool IsValidIdChar(char c)
|
||||||
|
{
|
||||||
|
var cat = CharUnicodeInfo.GetUnicodeCategory(c);
|
||||||
|
|
||||||
|
return
|
||||||
|
char.IsLetterOrDigit(c) ||
|
||||||
|
cat == UnicodeCategory.ConnectorPunctuation ||
|
||||||
|
cat == UnicodeCategory.NonSpacingMark ||
|
||||||
|
cat == UnicodeCategory.SpacingCombiningMark ||
|
||||||
|
cat == UnicodeCategory.EnclosingMark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string EnsureResourceExtension(string logicalName, string resourceFilePath)
|
||||||
|
{
|
||||||
|
string resourceExtension = Path.GetExtension(resourceFilePath);
|
||||||
|
if (!string.IsNullOrEmpty(resourceExtension))
|
||||||
|
{
|
||||||
|
if (!logicalName.EndsWith(resourceExtension, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
logicalName += resourceExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return logicalName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.DotNet.Tools.Common;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools.Compiler
|
||||||
|
{
|
||||||
|
internal static class ResourcePathUtility
|
||||||
|
{
|
||||||
|
public static string GetResourceName(string projectFolder, string resourcePath)
|
||||||
|
{
|
||||||
|
// If the file is outside of the project folder, we are assuming it is directly in the root
|
||||||
|
// otherwise, keep the folders that are inside the project
|
||||||
|
return PathUtility.IsChildOfDirectory(projectFolder, resourcePath) ?
|
||||||
|
PathUtility.GetRelativePath(projectFolder, resourcePath) :
|
||||||
|
Path.GetFileName(resourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsResxResourceFile(string fileName)
|
||||||
|
{
|
||||||
|
var ext = Path.GetExtension(fileName);
|
||||||
|
|
||||||
|
return
|
||||||
|
string.Equals(ext, ".resx", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(ext, ".restext", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(ext, ".resources", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
src/Microsoft.DotNet.Tools.Run/project.json
Normal file
30
src/Microsoft.DotNet.Tools.Run/project.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "dotnet-run",
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-23428",
|
||||||
|
|
||||||
|
"System.Console": "4.0.0-beta-23428",
|
||||||
|
"System.Collections": "4.0.11-beta-23428",
|
||||||
|
"System.Linq": "4.0.1-beta-23428",
|
||||||
|
"System.Diagnostics.Process": "4.1.0-beta-23428",
|
||||||
|
"System.IO.FileSystem": "4.0.1-beta-23428",
|
||||||
|
|
||||||
|
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||||
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
|
"type": "build",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||||
|
"type": "build",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"Microsoft.Net.Compilers.netcore": "1.1.0-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"dnxcore50": { }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue