Merge pull request #985 from brthor/525/arg_forwarding
Argument Forwarding Changes #525
This commit is contained in:
commit
ea43482551
66 changed files with 1274 additions and 408 deletions
|
@ -2,7 +2,7 @@
|
|||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<clear />
|
||||
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" />
|
||||
<add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
||||
|
|
|
@ -10,7 +10,7 @@ param(
|
|||
$toolsDir = $toolsDir.TrimEnd('\')
|
||||
$versionArg = ""
|
||||
if ($versionSuffix -ne "") {
|
||||
$versionArg = "--version-suffix $versionSuffix"
|
||||
$versionArg = "--version-suffix"
|
||||
}
|
||||
|
||||
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
||||
|
@ -24,7 +24,7 @@ New-Item -ItemType Directory -Force -Path $IntermediatePackagesDir
|
|||
foreach ($ProjectName in $ProjectsToPack) {
|
||||
$ProjectFile = "$RepoRoot\src\$ProjectName\project.json"
|
||||
|
||||
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$Stage2CompilationDir\bin" --output "$IntermediatePackagesDir" --configuration "$Configuration" $versionArg
|
||||
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$Stage2CompilationDir\bin" --output "$IntermediatePackagesDir" --configuration "$Configuration" $versionArg $versionSuffix
|
||||
if (!$?) {
|
||||
Write-Host "$toolsDir\dotnet pack failed for: $ProjectFile"
|
||||
Exit 1
|
||||
|
|
|
@ -5,17 +5,18 @@ REM This file encapsulates the temporary steps to build the dotnet-compile-nativ
|
|||
REM The AppDepSDK package is a temporary artifact until we have CoreRT assemblies published to Nuget
|
||||
|
||||
set __ScriptDir=%~dp0
|
||||
set __RepoRoot=%__ScriptDir%\..\..
|
||||
set __RepoRoot=%__ScriptDir%..\..
|
||||
set __AppDepsProjectDir=%__RepoRoot%\src\Microsoft.DotNet.Tools.Compiler.Native\appdep
|
||||
|
||||
REM Get absolute path
|
||||
pushd %1
|
||||
set __OutputPath=%CD%\bin
|
||||
set __OutputPath=%__RepoRoot%\artifacts\win7-x64\stage2\bin
|
||||
popd
|
||||
|
||||
|
||||
pushd %__AppDepsProjectDir%
|
||||
rmdir /S /Q packages
|
||||
mkdir packages
|
||||
dotnet restore --packages %__AppDepsProjectDir%\packages
|
||||
set __AppDepSDK=%__AppDepsProjectDir%\packages\toolchain*\
|
||||
popd
|
||||
|
|
38
scripts/test/argument-forwarding-tests.ps1
Normal file
38
scripts/test/argument-forwarding-tests.ps1
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
$TestPackagesPath = "$RepoRoot\tests\packages"
|
||||
|
||||
$ArgTestRoot = "$RepoRoot\test\ArgumentForwardingTests"
|
||||
$ArgTestOutputRoot = "$RepoRoot\artifacts\tests\arg-forwarding"
|
||||
$ArgTestBin = "$ArgTestOutputRoot\$Configuration\dnxcore50"
|
||||
|
||||
dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$ArgTestOutputRoot" --configuration "$Configuration" "$ArgTestRoot\Reflector"
|
||||
if (!$?) {
|
||||
Write-Host Command failed: dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$ArgTestOutputRoot" --configuration "$Configuration" "$ArgTestRoot\Reflector"
|
||||
Exit 1
|
||||
}
|
||||
|
||||
dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$ArgTestOutputRoot" --configuration "$Configuration" "$ArgTestRoot\ArgumentForwardingTests"
|
||||
if (!$?) {
|
||||
Write-Host Command failed: dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$ArgTestOutputRoot" --configuration "$Configuration" "$ArgTestRoot\ArgumentForwardingTests"
|
||||
Exit 1
|
||||
}
|
||||
|
||||
cp "$ArgTestRoot\Reflector\reflector_cmd.cmd" "$ArgTestBin"
|
||||
|
||||
pushd "$ArgTestBin"
|
||||
|
||||
& ".\corerun" "xunit.console.netcore.exe" "ArgumentForwardingTests.dll" -xml "$_-testResults.xml" -notrait category=failing
|
||||
$exitCode = $LastExitCode
|
||||
|
||||
popd
|
||||
|
||||
# No need to output here, we'll get test results
|
||||
if ($exitCode -ne 0) {
|
||||
Exit 1
|
||||
}
|
31
scripts/test/argument-forwarding-tests.sh
Executable file
31
scripts/test/argument-forwarding-tests.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
ArgTestRoot="$REPOROOT/test/ArgumentForwardingTests"
|
||||
ArgTestOutputRoot="$REPOROOT/artifacts/tests/arg-forwarding"
|
||||
ArgTestBin="$ArgTestOutputRoot/$CONFIGURATION/dnxcore50"
|
||||
|
||||
dotnet publish --framework "dnxcore50" --output "$ArgTestOutputRoot" --configuration "$CONFIGURATION" "$ArgTestRoot/Reflector"
|
||||
dotnet publish --framework "dnxcore50" --output "$ArgTestOutputRoot" --configuration "$CONFIGURATION" "$ArgTestRoot/ArgumentForwardingTests"
|
||||
|
||||
|
||||
|
||||
pushd "$ArgTestBin"
|
||||
./corerun "xunit.console.netcore.exe" "ArgumentForwardingTests.dll" -xml "ArgumentForwardingTests-testResults.xml" -notrait category=failing
|
||||
popd
|
|
@ -17,6 +17,11 @@ $TestProjects = @(
|
|||
"Microsoft.DotNet.Tools.Builder.Tests"
|
||||
)
|
||||
|
||||
$TestScripts = @(
|
||||
"package-command-test.ps1",
|
||||
"argument-forwarding-tests.ps1"
|
||||
)
|
||||
|
||||
# Publish each test project
|
||||
$TestProjects | ForEach-Object {
|
||||
dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$TestBinRoot" --configuration "$Configuration" "$RepoRoot\test\$_"
|
||||
|
@ -64,11 +69,13 @@ $TestProjects | ForEach-Object {
|
|||
|
||||
popd
|
||||
|
||||
& $RepoRoot\scripts\test\package-command-test.ps1
|
||||
$exitCode = $LastExitCode
|
||||
if ($exitCode -ne 0) {
|
||||
$failCount += 1
|
||||
$failingTests += "package-command-test"
|
||||
$TestScripts | ForEach-Object {
|
||||
& "$RepoRoot\scripts\test\$_"
|
||||
$exitCode = $LastExitCode
|
||||
if ($exitCode -ne 0) {
|
||||
$failingTests += "$_"
|
||||
$failCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
if ($failCount -ne 0) {
|
||||
|
|
|
@ -27,6 +27,11 @@ TestProjects=( \
|
|||
Microsoft.DotNet.Tools.Builder.Tests \
|
||||
)
|
||||
|
||||
TestScripts=( \
|
||||
"package-command-test.sh" \
|
||||
"argument-forwarding-tests.sh" \
|
||||
)
|
||||
|
||||
for project in ${TestProjects[@]}
|
||||
do
|
||||
dotnet publish --framework "dnxcore50" --output "$TestBinRoot" --configuration "$CONFIGURATION" "$REPOROOT/test/$project"
|
||||
|
@ -58,11 +63,15 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
"$REPOROOT/scripts/test/package-command-test.sh"
|
||||
if [ $? -ne 0 ]; then
|
||||
failCount+=1
|
||||
failedTests+=("package-command-test.sh")
|
||||
fi
|
||||
for script in ${TestScripts[@]}
|
||||
do
|
||||
"$REPOROOT/scripts/test/$script"
|
||||
exitCode=$?
|
||||
if [ $exitCode -ne 0 ]; then
|
||||
failedTests+=($script)
|
||||
failCount+=1
|
||||
fi
|
||||
done
|
||||
|
||||
for test in ${failedTests[@]}
|
||||
do
|
||||
|
|
206
src/Microsoft.DotNet.Cli.Utils/ArgumentEscaper.cs
Normal file
206
src/Microsoft.DotNet.Cli.Utils/ArgumentEscaper.cs
Normal file
|
@ -0,0 +1,206 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils
|
||||
{
|
||||
public static class ArgumentEscaper
|
||||
{
|
||||
/// <summary>
|
||||
/// Undo the processing which took place to create string[] args in Main,
|
||||
/// so that the next process will receive the same string[] args
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static string EscapeAndConcatenateArgArrayForProcessStart(IEnumerable<string> args)
|
||||
{
|
||||
return string.Join(" ", EscapeArgArray(args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undo the processing which took place to create string[] args in Main,
|
||||
/// so that the next process will receive the same string[] args
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static string EscapeAndConcatenateArgArrayForCmdProcessStart(IEnumerable<string> args)
|
||||
{
|
||||
return string.Join(" ", EscapeArgArrayForCmd(args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undo the processing which took place to create string[] args in Main,
|
||||
/// so that the next process will receive the same string[] args
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
private static IEnumerable<string> EscapeArgArray(IEnumerable<string> args)
|
||||
{
|
||||
var escapedArgs = new List<string>();
|
||||
|
||||
foreach (var arg in args)
|
||||
{
|
||||
escapedArgs.Add(EscapeArg(arg));
|
||||
}
|
||||
|
||||
return escapedArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This prefixes every character with the '^' character to force cmd to
|
||||
/// interpret the argument string literally. An alternative option would
|
||||
/// be to do this only for cmd metacharacters.
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
private static IEnumerable<string> EscapeArgArrayForCmd(IEnumerable<string> arguments)
|
||||
{
|
||||
var escapedArgs = new List<string>();
|
||||
|
||||
foreach (var arg in arguments)
|
||||
{
|
||||
escapedArgs.Add(EscapeArgForCmd(arg));
|
||||
}
|
||||
|
||||
return escapedArgs;
|
||||
}
|
||||
|
||||
private static string EscapeArg(string arg)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var quoted = ShouldSurroundWithQuotes(arg);
|
||||
if (quoted) sb.Append("\"");
|
||||
|
||||
for (int i = 0; i < arg.Length; ++i)
|
||||
{
|
||||
var backslashCount = 0;
|
||||
|
||||
// Consume All Backslashes
|
||||
while (i < arg.Length && arg[i] == '\\')
|
||||
{
|
||||
backslashCount++;
|
||||
i++;
|
||||
}
|
||||
|
||||
// Escape any backslashes at the end of the arg
|
||||
// This ensures the outside quote is interpreted as
|
||||
// an argument delimiter
|
||||
if (i == arg.Length)
|
||||
{
|
||||
sb.Append('\\', 2 * backslashCount);
|
||||
}
|
||||
|
||||
// Escape any preceding backslashes and the quote
|
||||
else if (arg[i] == '"')
|
||||
{
|
||||
sb.Append('\\', (2 * backslashCount) + 1);
|
||||
sb.Append('"');
|
||||
}
|
||||
|
||||
// Output any consumed backslashes and the character
|
||||
else
|
||||
{
|
||||
sb.Append('\\', backslashCount);
|
||||
sb.Append(arg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (quoted) sb.Append("\"");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare as single argument to
|
||||
/// roundtrip properly through cmd.
|
||||
///
|
||||
/// This prefixes every character with the '^' character to force cmd to
|
||||
/// interpret the argument string literally. An alternative option would
|
||||
/// be to do this only for cmd metacharacters.
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
private static string EscapeArgForCmd(string argument)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var quoted = ShouldSurroundWithQuotes(argument);
|
||||
|
||||
if (quoted) sb.Append("^\"");
|
||||
|
||||
foreach (var character in argument)
|
||||
{
|
||||
|
||||
if (character == '"')
|
||||
{
|
||||
|
||||
sb.Append('^');
|
||||
sb.Append('"');
|
||||
sb.Append('^');
|
||||
sb.Append(character);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("^");
|
||||
sb.Append(character);
|
||||
}
|
||||
}
|
||||
|
||||
if (quoted) sb.Append("^\"");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare as single argument to
|
||||
/// roundtrip properly through cmd.
|
||||
///
|
||||
/// This prefixes every character with the '^' character to force cmd to
|
||||
/// interpret the argument string literally. An alternative option would
|
||||
/// be to do this only for cmd metacharacters.
|
||||
///
|
||||
/// See here for more info:
|
||||
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
internal static bool ShouldSurroundWithQuotes(string argument)
|
||||
{
|
||||
// Don't quote already quoted strings
|
||||
if (argument.StartsWith("\"", StringComparison.Ordinal) &&
|
||||
argument.EndsWith("\"", StringComparison.Ordinal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only quote if whitespace exists in the string
|
||||
if (argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,20 +39,25 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
ResolutionStrategy = commandSpec.ResolutionStrategy;
|
||||
}
|
||||
|
||||
public static Command Create(string commandName, IEnumerable<string> args, NuGetFramework framework = null)
|
||||
/// <summary>
|
||||
/// Create a command with the specified arg array. Args will be
|
||||
/// escaped properly to ensure that exactly the strings in this
|
||||
/// array will be present in the corresponding argument array
|
||||
/// in the command's process.
|
||||
/// </summary>
|
||||
/// <param name="commandName"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <param name="framework"></param>
|
||||
/// <returns></returns>
|
||||
public static Command Create(string commandName, IEnumerable<string> args, NuGetFramework framework = null, bool useComSpec = false)
|
||||
{
|
||||
return Create(commandName, string.Join(" ", args), framework);
|
||||
}
|
||||
|
||||
public static Command Create(string commandName, string args, NuGetFramework framework = null)
|
||||
{
|
||||
var commandSpec = CommandResolver.TryResolveCommandSpec(commandName, args, framework);
|
||||
var commandSpec = CommandResolver.TryResolveCommandSpec(commandName, args, framework, useComSpec=useComSpec);
|
||||
|
||||
if (commandSpec == null)
|
||||
{
|
||||
throw new CommandUnknownException(commandName);
|
||||
}
|
||||
|
||||
|
||||
var command = new Command(commandSpec);
|
||||
|
||||
return command;
|
||||
|
@ -60,6 +65,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
public CommandResult Execute()
|
||||
{
|
||||
|
||||
Reporter.Verbose.WriteLine($"Running {_process.StartInfo.FileName} {_process.StartInfo.Arguments}");
|
||||
|
||||
ThrowIfRunning();
|
||||
|
|
|
@ -12,45 +12,52 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
internal static class CommandResolver
|
||||
{
|
||||
public static CommandSpec TryResolveCommandSpec(string commandName, string args, NuGetFramework framework = null)
|
||||
public static CommandSpec TryResolveCommandSpec(string commandName, IEnumerable<string> args, NuGetFramework framework = null, bool useComSpec = false)
|
||||
{
|
||||
return ResolveFromRootedCommand(commandName, args) ??
|
||||
ResolveFromProjectDependencies(commandName, args, framework) ??
|
||||
ResolveFromProjectTools(commandName, args) ??
|
||||
ResolveFromAppBase(commandName, args) ??
|
||||
ResolveFromPath(commandName, args);
|
||||
return ResolveFromRootedCommand(commandName, args, useComSpec) ??
|
||||
ResolveFromProjectDependencies(commandName, args, framework, useComSpec) ??
|
||||
ResolveFromProjectTools(commandName, args, useComSpec) ??
|
||||
ResolveFromAppBase(commandName, args, useComSpec) ??
|
||||
ResolveFromPath(commandName, args, useComSpec);
|
||||
}
|
||||
|
||||
private static CommandSpec ResolveFromPath(string commandName, string args)
|
||||
private static CommandSpec ResolveFromPath(string commandName, IEnumerable<string> args, bool useComSpec = false)
|
||||
{
|
||||
var commandPath = Env.GetCommandPath(commandName);
|
||||
|
||||
return commandPath == null
|
||||
? null
|
||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.Path);
|
||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.Path, useComSpec);
|
||||
}
|
||||
|
||||
private static CommandSpec ResolveFromAppBase(string commandName, string args)
|
||||
private static CommandSpec ResolveFromAppBase(string commandName, IEnumerable<string> args, bool useComSpec = false)
|
||||
{
|
||||
var commandPath = Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, commandName);
|
||||
|
||||
return commandPath == null
|
||||
? null
|
||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory);
|
||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory, useComSpec);
|
||||
}
|
||||
|
||||
private static CommandSpec ResolveFromRootedCommand(string commandName, string args)
|
||||
private static CommandSpec ResolveFromRootedCommand(string commandName, IEnumerable<string> args, bool useComSpec = false)
|
||||
{
|
||||
if (Path.IsPathRooted(commandName))
|
||||
{
|
||||
return new CommandSpec(commandName, args, CommandResolutionStrategy.Path);
|
||||
if (useComSpec)
|
||||
{
|
||||
return CreateComSpecCommandSpec(commandName, args, CommandResolutionStrategy.Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
||||
return new CommandSpec(commandName, escapedArgs, CommandResolutionStrategy.Path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CommandSpec ResolveFromProjectDependencies(string commandName, string args,
|
||||
NuGetFramework framework)
|
||||
public static CommandSpec ResolveFromProjectDependencies(string commandName, IEnumerable<string> args,
|
||||
NuGetFramework framework, bool useComSpec = false)
|
||||
{
|
||||
if (framework == null) return null;
|
||||
|
||||
|
@ -64,7 +71,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
var depsPath = GetDepsPath(projectContext, Constants.DefaultConfiguration);
|
||||
|
||||
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath);
|
||||
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath, useComSpec);
|
||||
}
|
||||
|
||||
private static ProjectContext GetProjectContext(NuGetFramework framework)
|
||||
|
@ -93,7 +100,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
e == FileNameSuffixes.DotNet.DynamicLib));
|
||||
}
|
||||
|
||||
public static CommandSpec ResolveFromProjectTools(string commandName, string args)
|
||||
public static CommandSpec ResolveFromProjectTools(string commandName, IEnumerable<string> args, bool useComSpec = false)
|
||||
{
|
||||
var context = GetProjectContext(FrameworkConstants.CommonFrameworks.DnxCore50);
|
||||
|
||||
|
@ -129,7 +136,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
: null;
|
||||
}
|
||||
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, string args, string packageDir)
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, IEnumerable<string> args, string packageDir)
|
||||
{
|
||||
var commandPackage = new PackageFolderReader(packageDir);
|
||||
|
||||
|
@ -138,8 +145,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return ConfigureCommandFromPackage(commandName, args, files, packageDir);
|
||||
}
|
||||
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, string args,
|
||||
PackageDescription commandPackage, ProjectContext projectContext, string depsPath = null)
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, IEnumerable<string> args,
|
||||
PackageDescription commandPackage, ProjectContext projectContext, string depsPath = null, bool useComSpec = false)
|
||||
{
|
||||
var files = commandPackage.Library.Files;
|
||||
|
||||
|
@ -149,11 +156,11 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
var packageDir = Path.Combine(packageRoot, packagePath);
|
||||
|
||||
return ConfigureCommandFromPackage(commandName, args, files, packageDir, depsPath);
|
||||
return ConfigureCommandFromPackage(commandName, args, files, packageDir, depsPath, useComSpec);
|
||||
}
|
||||
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, string args,
|
||||
IEnumerable<string> files, string packageDir, string depsPath = null)
|
||||
private static CommandSpec ConfigureCommandFromPackage(string commandName, IEnumerable<string> args,
|
||||
IEnumerable<string> files, string packageDir, string depsPath = null, bool useComSpec = false)
|
||||
{
|
||||
var fileName = string.Empty;
|
||||
|
||||
|
@ -169,21 +176,33 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
fileName = CoreHost.HostExePath;
|
||||
|
||||
var depsArg = string.Empty;
|
||||
var additionalArgs = new List<string>();
|
||||
additionalArgs.Add(dllPath);
|
||||
|
||||
if (depsPath != null)
|
||||
{
|
||||
depsArg = $"\"--depsfile:{depsPath}\" ";
|
||||
additionalArgs.Add("--depsfile");
|
||||
additionalArgs.Add(depsPath);
|
||||
}
|
||||
|
||||
args = $"\"{dllPath}\" {depsArg}{args}";
|
||||
args = additionalArgs.Concat(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = Path.Combine(packageDir, commandPath);
|
||||
}
|
||||
|
||||
return new CommandSpec(fileName, args, CommandResolutionStrategy.NugetPackage);
|
||||
if (useComSpec)
|
||||
{
|
||||
return CreateComSpecCommandSpec(fileName, args, CommandResolutionStrategy.NugetPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
||||
return new CommandSpec(fileName, escapedArgs, CommandResolutionStrategy.NugetPackage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static string GetDepsPath(ProjectContext context, string buildConfiguration)
|
||||
|
@ -192,23 +211,64 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
context.ProjectFile.Name + FileNameSuffixes.Deps);
|
||||
}
|
||||
|
||||
private static CommandSpec CreateCommandSpecPreferringExe(string commandName, string args, string commandPath,
|
||||
CommandResolutionStrategy resolutionStrategy)
|
||||
private static CommandSpec CreateCommandSpecPreferringExe(
|
||||
string commandName,
|
||||
IEnumerable<string> args,
|
||||
string commandPath,
|
||||
CommandResolutionStrategy resolutionStrategy,
|
||||
bool useComSpec = false)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
|
||||
Path.GetExtension(commandPath).Equals(".cmd", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var preferredCommandPath = Env.GetCommandPath(commandName, ".exe");
|
||||
|
||||
if (preferredCommandPath != null)
|
||||
// Use cmd if we can't find an exe
|
||||
if (preferredCommandPath == null)
|
||||
{
|
||||
commandPath = Environment.GetEnvironmentVariable("ComSpec");
|
||||
|
||||
args = $"/S /C \"\"{preferredCommandPath}\" {args}\"";
|
||||
useComSpec = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
commandPath = preferredCommandPath;
|
||||
}
|
||||
}
|
||||
|
||||
return new CommandSpec(commandPath, args, resolutionStrategy);
|
||||
if (useComSpec)
|
||||
{
|
||||
return CreateComSpecCommandSpec(commandPath, args, resolutionStrategy);
|
||||
}
|
||||
else
|
||||
{
|
||||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
||||
return new CommandSpec(commandPath, escapedArgs, resolutionStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandSpec CreateComSpecCommandSpec(
|
||||
string command,
|
||||
IEnumerable<string> args,
|
||||
CommandResolutionStrategy resolutionStrategy)
|
||||
{
|
||||
// To prevent Command Not Found, comspec gets passed in as
|
||||
// the command already in some cases
|
||||
var comSpec = Environment.GetEnvironmentVariable("ComSpec");
|
||||
if (command.Equals(comSpec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
command = args.FirstOrDefault();
|
||||
args = args.Skip(1);
|
||||
}
|
||||
var cmdEscapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForCmdProcessStart(args);
|
||||
|
||||
if (ArgumentEscaper.ShouldSurroundWithQuotes(command))
|
||||
{
|
||||
command = $"\"{command}\"";
|
||||
}
|
||||
|
||||
var escapedArgString = $"/s /c \"{command} {cmdEscapedArgs}\"";
|
||||
|
||||
return new CommandSpec(comSpec, escapedArgString, resolutionStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return null;
|
||||
}
|
||||
|
||||
var useComSpec = false;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Only forward slashes are used in script blocks. Replace with backslashes to correctly
|
||||
|
@ -45,10 +47,10 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
var comSpec = Environment.GetEnvironmentVariable("ComSpec");
|
||||
if (!string.IsNullOrEmpty(comSpec))
|
||||
{
|
||||
scriptArguments =
|
||||
new[] { comSpec, "/S", "/C", "\"" }
|
||||
useComSpec=true;
|
||||
|
||||
scriptArguments = new string[] { comSpec }
|
||||
.Concat(scriptArguments)
|
||||
.Concat(new[] { "\"" })
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +90,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
return Command.Create(scriptArguments.FirstOrDefault(), string.Join(" ", scriptArguments.Skip(1)))
|
||||
return Command.Create(scriptArguments.FirstOrDefault(), scriptArguments.Skip(1), useComSpec: useComSpec)
|
||||
.WorkingDirectory(project.ProjectDirectory);
|
||||
}
|
||||
private static Func<string, string> WrapVariableDictionary(IDictionary<string, string> contextVariables)
|
||||
|
|
|
@ -119,7 +119,7 @@ Common Commands:
|
|||
{
|
||||
if (appArgs.Any())
|
||||
{
|
||||
return Command.Create("dotnet-" + appArgs.First(), "--help")
|
||||
return Command.Create("dotnet-" + appArgs.First(), new string[] { "--help" })
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
var existingAttributes = new List<Type>();
|
||||
foreach (var sourceFile in sourceFiles)
|
||||
{
|
||||
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile));
|
||||
var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile.Trim('"')));
|
||||
var root = tree.GetRoot();
|
||||
|
||||
// assembly attributes can be only on first level
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"System.Threading.ThreadPool": "4.0.10-beta-23704",
|
||||
"System.Threading.ThreadPool": "4.0.10-rc2-23704",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
|
@ -14,8 +14,8 @@
|
|||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-15935",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15935",
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-16011",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-16011",
|
||||
"Newtonsoft.Json": "7.0.1"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"System.Xml.XDocument": "4.0.11-rc2-23704",
|
||||
"NuGet.Packaging": "3.4.0-beta-*",
|
||||
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15964",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15975",
|
||||
"Microsoft.Extensions.JsonParser.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
|
||||
if (!newInputs.Any())
|
||||
{
|
||||
Reporter.Output.WriteLine($"\nProject {project.ProjectName()} was previoulsy compiled. Skipping compilation.");
|
||||
Reporter.Output.WriteLine($"\nProject {project.ProjectName()} was previously compiled. Skipping compilation.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions)
|
||||
{
|
||||
var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project)
|
||||
.Select(commandName => Command.Create(commandName, "", project.TargetFramework))
|
||||
.Select(commandName => Command.Create(commandName, Enumerable.Empty<string>(), project.TargetFramework))
|
||||
.Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path));
|
||||
|
||||
foreach (var pathCommand in pathCommands)
|
||||
|
@ -257,13 +257,24 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
|
||||
private bool InvokeCompileOnDependency(ProjectDescription projectDependency)
|
||||
{
|
||||
var compileResult = Command.Create("dotnet-compile",
|
||||
$"--framework {projectDependency.Framework} " +
|
||||
$"--configuration {_args.ConfigValue} " +
|
||||
$"--output \"{_args.OutputValue}\" " +
|
||||
$"--temp-output \"{_args.IntermediateValue}\" " +
|
||||
(_args.NoHostValue ? "--no-host " : string.Empty) +
|
||||
$"\"{projectDependency.Project.ProjectDirectory}\"")
|
||||
var args = new List<string>();
|
||||
|
||||
args.Add("--framework");
|
||||
args.Add($"{projectDependency.Framework}");
|
||||
args.Add("--configuration");
|
||||
args.Add($"{_args.ConfigValue}");
|
||||
args.Add("--output");
|
||||
args.Add($"{_args.OutputValue}");
|
||||
args.Add("--temp-output");
|
||||
args.Add($"{_args.IntermediateValue}");
|
||||
args.Add($"{projectDependency.Project.ProjectDirectory}");
|
||||
|
||||
if (_args.NoHostValue)
|
||||
{
|
||||
args.Add("--no-host");
|
||||
}
|
||||
|
||||
var compileResult = Command.Create("dotnet-compile", args)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
|
@ -274,20 +285,59 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
private bool InvokeCompileOnRootProject()
|
||||
{
|
||||
// todo: add methods to CompilerCommandApp to generate the arg string?
|
||||
var compileResult = Command.Create("dotnet-compile",
|
||||
$"--framework {_rootProject.TargetFramework} " +
|
||||
$"--configuration {_args.ConfigValue} " +
|
||||
$"--output \"{_args.OutputValue}\" " +
|
||||
$"--temp-output \"{_args.IntermediateValue}\" " +
|
||||
(_args.NoHostValue ? "--no-host " : string.Empty) +
|
||||
//nativeArgs
|
||||
(_args.IsNativeValue ? "--native " : string.Empty) +
|
||||
(_args.IsCppModeValue ? "--cpp " : string.Empty) +
|
||||
(!string.IsNullOrWhiteSpace(_args.ArchValue) ? $"--arch {_args.ArchValue} " : string.Empty) +
|
||||
(!string.IsNullOrWhiteSpace(_args.IlcArgsValue) ? $"--ilcargs \"{_args.IlcArgsValue}\" " : string.Empty) +
|
||||
(!string.IsNullOrWhiteSpace(_args.IlcPathValue) ? $"--ilcpath \"{_args.IlcPathValue}\" " : string.Empty) +
|
||||
(!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue) ? $"--ilcsdkpath \"{_args.IlcSdkPathValue}\" " : string.Empty) +
|
||||
$"\"{_rootProject.ProjectDirectory}\"")
|
||||
var args = new List<string>();
|
||||
args.Add("--framework");
|
||||
args.Add(_rootProject.TargetFramework.ToString());
|
||||
args.Add("--configuration");
|
||||
args.Add(_args.ConfigValue);
|
||||
args.Add("--output");
|
||||
args.Add(_args.OutputValue);
|
||||
args.Add("--temp-output");
|
||||
args.Add(_args.IntermediateValue);
|
||||
|
||||
if (_args.NoHostValue)
|
||||
{
|
||||
args.Add("--no-host");
|
||||
}
|
||||
|
||||
//native args
|
||||
if (_args.IsNativeValue)
|
||||
{
|
||||
args.Add("--native");
|
||||
}
|
||||
|
||||
if (_args.IsCppModeValue)
|
||||
{
|
||||
args.Add("--cpp");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.ArchValue))
|
||||
{
|
||||
args.Add("--arch");
|
||||
args.Add(_args.ArchValue);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.IlcArgsValue))
|
||||
{
|
||||
args.Add("--ilcargs");
|
||||
args.Add(_args.IlcArgsValue);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.IlcPathValue))
|
||||
{
|
||||
args.Add("--ilcpath");
|
||||
args.Add(_args.IlcPathValue);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue))
|
||||
{
|
||||
args.Add("--ilcsdkpath");
|
||||
args.Add(_args.IlcSdkPathValue);
|
||||
}
|
||||
|
||||
args.Add(_rootProject.ProjectDirectory);
|
||||
|
||||
var compileResult = Command.Create("dotnet-compile",args)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
|
|
|
@ -79,31 +79,33 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
return returnCode;
|
||||
}
|
||||
|
||||
var translated = TranslateCommonOptions(commonOptions, outputName);
|
||||
var translated = TranslateCommonOptions(commonOptions, outputName.Trim('"'));
|
||||
|
||||
var allArgs = new List<string>(translated);
|
||||
allArgs.AddRange(GetDefaultOptions());
|
||||
|
||||
// Generate assembly info
|
||||
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
|
||||
var tempOutputStrippedSpaces = tempOutDir.Trim('"');
|
||||
var assemblyInfo = Path.Combine(tempOutputStrippedSpaces, $"dotnet-compile.assemblyinfo.cs");
|
||||
|
||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.Generate(assemblyInfoOptions, sources));
|
||||
allArgs.Add($"\"{assemblyInfo}\"");
|
||||
|
||||
if (outputName != null)
|
||||
{
|
||||
allArgs.Add($"-out:\"{outputName}\"");
|
||||
allArgs.Add($"-out:\"{outputName.Trim('"')}\"");
|
||||
}
|
||||
|
||||
allArgs.AddRange(references.Select(r => $"-r:\"{r}\""));
|
||||
allArgs.AddRange(resources.Select(resource => $"-resource:{resource}"));
|
||||
allArgs.AddRange(sources.Select(s => $"\"{s}\""));
|
||||
allArgs.AddRange(references.Select(r => $"-r:\"{r.Trim('"')}\""));
|
||||
allArgs.AddRange(resources.Select(resource => $"-resource:{resource.Trim('"')}"));
|
||||
allArgs.AddRange(sources.Select(s => $"\"{s.Trim('"')}\""));
|
||||
|
||||
var rsp = Path.Combine(tempOutDir, "dotnet-compile-csc.rsp");
|
||||
var rsp = Path.Combine(tempOutputStrippedSpaces, "dotnet-compile-csc.rsp");
|
||||
|
||||
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
||||
|
||||
// Execute CSC!
|
||||
var result = RunCsc($"-noconfig @\"{rsp}\"")
|
||||
var result = RunCsc(new string[] { $"-noconfig", "@" + $"{rsp}" })
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
@ -192,7 +194,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
|
||||
if (options.GenerateXmlDocumentation == true)
|
||||
{
|
||||
commonArgs.Add($"-doc:{Path.ChangeExtension(outputName, "xml")}");
|
||||
commonArgs.Add($"-doc:\"{Path.ChangeExtension(outputName.Trim('"'), "xml")}\"");
|
||||
}
|
||||
|
||||
if (options.EmitEntryPoint != true)
|
||||
|
@ -214,7 +216,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
return languageVersion;
|
||||
}
|
||||
|
||||
private static Command RunCsc(string cscArgs)
|
||||
private static Command RunCsc(string[] cscArgs)
|
||||
{
|
||||
// Locate CoreRun
|
||||
return Command.Create("csc", cscArgs);
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
|||
// Generate assembly info
|
||||
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.fs");
|
||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
|
||||
allArgs.Add($"\"{assemblyInfo}\"");
|
||||
allArgs.Add($"{assemblyInfo}");
|
||||
|
||||
//HACK fsc raise error FS0208 if target exe doesnt have extension .exe
|
||||
bool hackFS0208 = commonOptions.EmitEntryPoint == true;
|
||||
|
@ -100,18 +100,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
|||
outputName = Path.ChangeExtension(outputName, ".exe");
|
||||
}
|
||||
|
||||
allArgs.Add($"--out:\"{outputName}\"");
|
||||
allArgs.Add($"--out:");
|
||||
allArgs.Add($"{outputName}");
|
||||
}
|
||||
|
||||
allArgs.AddRange(references.Select(r => $"-r:\"{r}\""));
|
||||
allArgs.AddRange(resources.Select(resource => $"--resource:{resource}"));
|
||||
allArgs.AddRange(sources.Select(s => $"\"{s}\""));
|
||||
foreach (var reference in references)
|
||||
{
|
||||
allArgs.Add("-r");
|
||||
allArgs.Add($"{reference}");
|
||||
}
|
||||
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
allArgs.Add("--resource");
|
||||
allArgs.Add($"{resource}");
|
||||
}
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
allArgs.Add($"{source}");
|
||||
}
|
||||
|
||||
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
|
||||
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
||||
|
||||
// Execute FSC!
|
||||
var result = RunFsc(string.Join(" ", allArgs))
|
||||
var result = RunFsc(allArgs)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
@ -192,11 +206,16 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
|||
return commonArgs;
|
||||
}
|
||||
|
||||
private static Command RunFsc(string fscArgs)
|
||||
private static Command RunFsc(List<string> fscArgs)
|
||||
{
|
||||
var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName);
|
||||
var fscExe = Path.Combine(AppContext.BaseDirectory, "fsc.exe");
|
||||
return Command.Create(corerun, $"\"{fscExe}\" {fscArgs}");
|
||||
|
||||
List<string> args = new List<string>();
|
||||
args.Add(fscExe);
|
||||
args.AddRange(fscArgs);
|
||||
|
||||
return Command.Create(corerun, args.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
|
@ -13,15 +8,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
private readonly string ExecutableName = "corerun" + Constants.ExeSuffix;
|
||||
private readonly string ILCompiler = "ilc.exe";
|
||||
private IEnumerable<string> Args;
|
||||
private NativeCompileSettings config;
|
||||
|
||||
private static readonly Dictionary<NativeIntermediateMode, string> ModeOutputExtensionMap = new Dictionary<NativeIntermediateMode, string>
|
||||
{
|
||||
{ NativeIntermediateMode.cpp, ".cpp" },
|
||||
{ NativeIntermediateMode.ryujit, ".obj" }
|
||||
};
|
||||
|
||||
private string ArgStr { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
|
||||
public ILCompilerInvoker(NativeCompileSettings config)
|
||||
{
|
||||
|
@ -39,28 +33,31 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
throw new FileNotFoundException("Unable to find ILCompiler at " + managedPath);
|
||||
}
|
||||
|
||||
argsList.Add($"\"{managedPath}\"");
|
||||
argsList.Add($"{managedPath}");
|
||||
|
||||
// Input File
|
||||
var inputFilePath = config.InputManagedAssemblyPath;
|
||||
argsList.Add($"\"{inputFilePath}\"");
|
||||
argsList.Add($"{inputFilePath}");
|
||||
|
||||
// System.Private.* References
|
||||
var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll"))
|
||||
{
|
||||
argsList.Add($"-r \"{reference}\"");
|
||||
argsList.Add($"-r");
|
||||
argsList.Add($"{reference}");
|
||||
}
|
||||
|
||||
// AppDep References
|
||||
foreach (var reference in config.ReferencePaths)
|
||||
{
|
||||
argsList.Add($"-r \"{reference}\"");
|
||||
argsList.Add($"-r");
|
||||
argsList.Add($"{reference}");
|
||||
}
|
||||
|
||||
// Set Output DetermineOutFile
|
||||
var outFile = DetermineOutputFile(config);
|
||||
argsList.Add($"-out \"{outFile}\"");
|
||||
argsList.Add($"-out");
|
||||
argsList.Add($"{outFile}");
|
||||
|
||||
// Add Mode Flag TODO
|
||||
if (config.NativeMode == NativeIntermediateMode.cpp)
|
||||
|
@ -74,14 +71,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
argsList.Add(config.IlcArgs);
|
||||
}
|
||||
|
||||
this.ArgStr = string.Join(" ", argsList);
|
||||
Args = argsList;
|
||||
}
|
||||
|
||||
|
||||
public int Invoke()
|
||||
{
|
||||
var executablePath = Path.Combine(config.IlcPath, ExecutableName);
|
||||
|
||||
var result = Command.Create(executablePath, ArgStr)
|
||||
var result = Command.Create(executablePath, Args)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -1,43 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
public class LinuxCppCompileStep : IPlatformNativeStep
|
||||
{
|
||||
private readonly string CompilerName = "clang-3.5";
|
||||
private readonly string InputExtension = ".cpp";
|
||||
private const string CompilerName = "clang-3.5";
|
||||
private const string InputExtension = ".cpp";
|
||||
|
||||
// TODO: debug/release support
|
||||
private readonly string cLibsFlags = "-lm -ldl";
|
||||
private readonly string cflags = "-g -lstdc++ -lrt -Wno-invalid-offsetof -pthread";
|
||||
private readonly string [] _cLibsFlags = { "-lm", "-ldl"};
|
||||
private readonly string [] _cflags = { "-g", "-lstdc++", "-lrt", "-Wno-invalid-offsetof", "-pthread"};
|
||||
|
||||
private readonly string[] IlcSdkLibs = new string[]
|
||||
{
|
||||
"libbootstrappercpp.a",
|
||||
"libPortableRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
public IEnumerable<string> CompilerArgs { get; set; }
|
||||
|
||||
private readonly string[] appdeplibs = new string[]
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
private readonly string[] _ilcSdkLibs =
|
||||
{
|
||||
"libbootstrappercpp.a",
|
||||
"libPortableRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
|
||||
|
||||
private string CompilerArgStr { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
public LinuxCppCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
|
@ -63,11 +55,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var argsList = new List<string>();
|
||||
|
||||
// Flags
|
||||
argsList.Add(cflags);
|
||||
argsList.AddRange(_cflags);
|
||||
|
||||
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
|
||||
argsList.Add("-I");
|
||||
argsList.Add($"\"{ilcSdkIncPath}\"");
|
||||
argsList.Add($"{ilcSdkIncPath}");
|
||||
|
||||
// Input File
|
||||
var inCppFile = DetermineInFile(config);
|
||||
|
@ -80,33 +72,26 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
}
|
||||
|
||||
// ILC SDK Libs
|
||||
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var lib in IlcSdkLibs)
|
||||
{
|
||||
var libPath = Path.Combine(IlcSdkLibPath, lib);
|
||||
argsList.Add(libPath);
|
||||
}
|
||||
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
|
||||
|
||||
// AppDep Libs
|
||||
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/x64");
|
||||
foreach (var lib in appdeplibs)
|
||||
{
|
||||
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
|
||||
argsList.Add(appDeplibPath);
|
||||
}
|
||||
argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)));
|
||||
|
||||
argsList.Add(cLibsFlags);
|
||||
argsList.AddRange(_cLibsFlags);
|
||||
|
||||
// Output
|
||||
var libOut = DetermineOutputFile(config);
|
||||
argsList.Add($"-o \"{libOut}\"");
|
||||
argsList.Add($"-o");
|
||||
argsList.Add($"{libOut}");
|
||||
|
||||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
CompilerArgs = argsList;
|
||||
}
|
||||
|
||||
private int InvokeCompiler()
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
var result = Command.Create(CompilerName, CompilerArgs)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -1,44 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
public class LinuxRyuJitCompileStep : IPlatformNativeStep
|
||||
{
|
||||
private readonly string CompilerName = "clang-3.5";
|
||||
private readonly string InputExtension = ".obj";
|
||||
private const string CompilerName = "clang-3.5";
|
||||
private const string InputExtension = ".obj";
|
||||
private const string CompilerOutputExtension = "";
|
||||
|
||||
private readonly string CompilerOutputExtension = "";
|
||||
public List<string> CompilerArgs { get; set; }
|
||||
|
||||
// TODO: debug/release support
|
||||
private readonly string cflags = "-lstdc++ -lpthread -ldl -lm -lrt";
|
||||
private readonly string[] _cflags = {"-lstdc++", "-lpthread", "-ldl", "-lm", "-lrt"};
|
||||
private readonly string[] _ilcSdkLibs =
|
||||
{
|
||||
"libbootstrapper.a",
|
||||
"libRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
|
||||
private readonly string[] IlcSdkLibs = new string[]
|
||||
{
|
||||
"libbootstrapper.a",
|
||||
"libRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
|
||||
private readonly string[] appdeplibs = new string[]
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
|
||||
private string CompilerArgStr { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
public LinuxRyuJitCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
|
@ -64,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var argsList = new List<string>();
|
||||
|
||||
// Flags
|
||||
argsList.Add(cflags);
|
||||
argsList.AddRange(_cflags);
|
||||
|
||||
// Input File
|
||||
var inLibFile = DetermineInFile(config);
|
||||
|
@ -77,31 +67,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
}
|
||||
|
||||
// ILC SDK Libs
|
||||
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var lib in IlcSdkLibs)
|
||||
{
|
||||
var libPath = Path.Combine(IlcSdkLibPath, lib);
|
||||
argsList.Add(libPath);
|
||||
}
|
||||
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
|
||||
|
||||
// AppDep Libs
|
||||
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04", config.Architecture.ToString());
|
||||
foreach (var lib in appdeplibs)
|
||||
{
|
||||
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
|
||||
argsList.Add(appDepLibPath);
|
||||
}
|
||||
argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)));
|
||||
|
||||
// Output
|
||||
var libOut = DetermineOutputFile(config);
|
||||
argsList.Add($"-o \"{libOut}\"");
|
||||
argsList.Add($"-o");
|
||||
argsList.Add($"{libOut}");
|
||||
|
||||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
CompilerArgs = argsList;
|
||||
}
|
||||
|
||||
private int InvokeCompiler()
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
var result = Command.Create(CompilerName, CompilerArgs)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -12,34 +12,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public class MacCppCompileStep : IPlatformNativeStep
|
||||
{
|
||||
private readonly string CompilerName = "clang";
|
||||
private readonly string InputExtension = ".cpp";
|
||||
private const string CompilerName = "clang";
|
||||
public const string InputExtension = ".cpp";
|
||||
|
||||
// TODO: debug/release support
|
||||
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread";
|
||||
private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread"};
|
||||
|
||||
// Link to iconv APIs
|
||||
private readonly string libFlags = "-liconv";
|
||||
private const string LibFlags = "-liconv";
|
||||
|
||||
private readonly string[] IlcSdkLibs = new string[]
|
||||
{
|
||||
"libbootstrappercpp.a",
|
||||
"libPortableRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
private readonly string[] _ilcSdkLibs =
|
||||
{
|
||||
"libbootstrappercpp.a",
|
||||
"libPortableRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
|
||||
private readonly string[] appdeplibs = new string[]
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
private readonly string[] _appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
|
||||
private string CompilerArgStr { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
private List<string> CompilerArgs { get; set; }
|
||||
|
||||
public MacCppCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
|
@ -65,18 +63,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var argsList = new List<string>();
|
||||
|
||||
// Flags
|
||||
argsList.Add(cflags);
|
||||
argsList.AddRange(_cflags);
|
||||
|
||||
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
|
||||
argsList.Add("-I");
|
||||
argsList.Add($"\"{ilcSdkIncPath}\"");
|
||||
argsList.Add($"{ilcSdkIncPath}");
|
||||
|
||||
// Input File
|
||||
var inCppFile = DetermineInFile(config);
|
||||
argsList.Add(inCppFile);
|
||||
|
||||
// Lib flags
|
||||
argsList.Add(libFlags);
|
||||
argsList.Add(LibFlags);
|
||||
|
||||
// Pass the optional native compiler flags if specified
|
||||
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
|
||||
|
@ -85,11 +83,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
}
|
||||
|
||||
// ILC SDK Libs
|
||||
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var lib in IlcSdkLibs)
|
||||
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var libPath in _ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)))
|
||||
{
|
||||
var libPath = Path.Combine(IlcSdkLibPath, lib);
|
||||
|
||||
// Forward the library to linked to the linker
|
||||
argsList.Add("-Xlinker");
|
||||
argsList.Add(libPath);
|
||||
|
@ -97,23 +93,23 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
// AppDep Libs
|
||||
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10/x64");
|
||||
foreach (var lib in appdeplibs)
|
||||
foreach (var appDeplibPath in _appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)))
|
||||
{
|
||||
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
|
||||
argsList.Add("-Xlinker");
|
||||
argsList.Add(appDeplibPath);
|
||||
}
|
||||
|
||||
// Output
|
||||
var libOut = DetermineOutputFile(config);
|
||||
argsList.Add($"-o \"{libOut}\"");
|
||||
argsList.Add($"-o");
|
||||
argsList.Add($"{libOut}");
|
||||
|
||||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
CompilerArgs = argsList;
|
||||
}
|
||||
|
||||
private int InvokeCompiler()
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
var result = Command.Create(CompilerName, CompilerArgs)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -1,44 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
public class MacRyuJitCompileStep : IPlatformNativeStep
|
||||
{
|
||||
private readonly string CompilerName = "clang";
|
||||
private readonly string InputExtension = ".obj";
|
||||
private const string CompilerName = "clang";
|
||||
private const string InputExtension = ".obj";
|
||||
|
||||
private readonly string CompilerOutputExtension = "";
|
||||
private const string CompilerOutputExtension = "";
|
||||
|
||||
private IEnumerable<string> CompilerArgs;
|
||||
|
||||
// TODO: debug/release support
|
||||
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread -ldl -lm -liconv";
|
||||
private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread", "-ldl", "-lm", "-liconv" };
|
||||
|
||||
private readonly string[] IlcSdkLibs = new string[]
|
||||
{
|
||||
"libbootstrapper.a",
|
||||
"libRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
private readonly string[] _ilcSdkLibs =
|
||||
{
|
||||
"libbootstrapper.a",
|
||||
"libRuntime.a",
|
||||
"libSystem.Private.CoreLib.Native.a"
|
||||
};
|
||||
|
||||
private readonly string[] appdeplibs = new string[]
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
|
||||
private string CompilerArgStr { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
private readonly string[] appdeplibs =
|
||||
{
|
||||
"libSystem.Native.a"
|
||||
};
|
||||
|
||||
public MacRyuJitCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
|
@ -64,7 +56,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var argsList = new List<string>();
|
||||
|
||||
// Flags
|
||||
argsList.Add(cflags);
|
||||
argsList.AddRange(_cflags);
|
||||
|
||||
// Pass the optional native compiler flags if specified
|
||||
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
|
||||
|
@ -77,31 +69,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
argsList.Add("-Xlinker "+inLibFile);
|
||||
|
||||
// ILC SDK Libs
|
||||
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
foreach (var lib in IlcSdkLibs)
|
||||
{
|
||||
var libPath = Path.Combine(IlcSdkLibPath, lib);
|
||||
argsList.Add("-Xlinker "+libPath);
|
||||
}
|
||||
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
|
||||
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)).Select(libPath => "-Xlinker " + libPath));
|
||||
|
||||
// AppDep Libs
|
||||
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10", config.Architecture.ToString());
|
||||
foreach (var lib in appdeplibs)
|
||||
{
|
||||
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
|
||||
argsList.Add("-Xlinker "+appDepLibPath);
|
||||
}
|
||||
argsList.AddRange(appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)).Select(appDepLibPath => "-Xlinker " + appDepLibPath));
|
||||
|
||||
// Output
|
||||
var libOut = DetermineOutputFile(config);
|
||||
argsList.Add($"-o \"{libOut}\"");
|
||||
argsList.Add($"-o");
|
||||
argsList.Add($"{libOut}");
|
||||
|
||||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
this.CompilerArgs = argsList;
|
||||
}
|
||||
|
||||
private int InvokeCompiler()
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
var result = Command.Create(CompilerName, CompilerArgs)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private readonly string CompilerOutputExtension = ".obj";
|
||||
|
||||
private static readonly Dictionary<BuildConfiguration, string> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string>
|
||||
private static readonly Dictionary<BuildConfiguration, string[]> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string[]>
|
||||
{
|
||||
{ BuildConfiguration.debug, "/ZI /nologo /W3 /WX- /sdl /Od /D CPPCODEGEN /D WIN32 /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" },
|
||||
{ BuildConfiguration.release, "/Zi /nologo /W3 /WX- /sdl /O2 /Oi /GL /D CPPCODEGEN /D WIN32 /D NDEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" }
|
||||
{ BuildConfiguration.debug, new string[] {"/ZI", "/nologo", "/W3", "/WX-", "/sdl", "/Od", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm", "/EHsc", "/RTC1", "/MD", "/GS", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} },
|
||||
{ BuildConfiguration.release, new string[] {"/Zi", "/nologo", "/W3", "/WX-", "/sdl", "/O2", "/Oi", "/GL", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "NDEBUG", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm-", "/EHsc", "/MD", "/GS", "/Gy", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} }
|
||||
};
|
||||
|
||||
private string CompilerArgStr { get; set; }
|
||||
private IEnumerable<string> CompilerArgs { get; set; }
|
||||
|
||||
private NativeCompileSettings config;
|
||||
|
||||
|
@ -70,10 +70,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
// Add Includes
|
||||
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
|
||||
argsList.Add("/I");
|
||||
argsList.Add($"\"{ilcSdkIncPath}\"");
|
||||
argsList.Add($"{ilcSdkIncPath}");
|
||||
|
||||
// Configuration Based Compiler Options
|
||||
argsList.Add(ConfigurationCompilerOptionsMap[config.BuildType]);
|
||||
argsList.AddRange(ConfigurationCompilerOptionsMap[config.BuildType]);
|
||||
|
||||
// Pass the optional native compiler flags if specified
|
||||
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
|
||||
|
@ -83,13 +83,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
// Output
|
||||
var objOut = DetermineOutputFile(config);
|
||||
argsList.Add($"/Fo\"{objOut}\"");
|
||||
argsList.Add($"/Fo{objOut}");
|
||||
|
||||
// Input File
|
||||
var inCppFile = DetermineInFile(config);
|
||||
argsList.Add($"\"{inCppFile}\"");
|
||||
|
||||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
argsList.Add($"{inCppFile}");
|
||||
|
||||
this.CompilerArgs = argsList;
|
||||
}
|
||||
|
||||
private int InvokeCompiler()
|
||||
|
@ -97,7 +97,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||
var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName);
|
||||
|
||||
var result = Command.Create(compilerPath, CompilerArgStr)
|
||||
var result = Command.Create(compilerPath, CompilerArgs.ToArray())
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{ BuildConfiguration.release , new string[] { "msvcrt.lib" } }
|
||||
};
|
||||
|
||||
private string ArgStr { get; set; }
|
||||
private IEnumerable<string> Args { get; set; }
|
||||
private NativeCompileSettings config;
|
||||
|
||||
public WindowsLinkStep(NativeCompileSettings config)
|
||||
|
@ -95,10 +95,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
//Output
|
||||
var outFile = DetermineOutputFile(config);
|
||||
argsList.Add($"/out:\"{outFile}\"");
|
||||
argsList.Add($"/out:{outFile}");
|
||||
|
||||
// Constant Libs
|
||||
argsList.Add(string.Join(" ", ConstantLinkLibs));
|
||||
foreach (var lib in ConstantLinkLibs)
|
||||
{
|
||||
argsList.Add(lib);
|
||||
}
|
||||
|
||||
// ILC SDK Libs
|
||||
var SDKLibs = IlcSdkLibMap[config.NativeMode];
|
||||
|
@ -106,19 +109,19 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
foreach (var lib in SDKLibs)
|
||||
{
|
||||
var sdkLibPath = Path.Combine(IlcSdkLibPath, lib);
|
||||
argsList.Add($"\"{sdkLibPath}\"");
|
||||
argsList.Add($"{sdkLibPath}");
|
||||
}
|
||||
|
||||
// Configuration Based Libs
|
||||
var configLibs = ConfigurationLinkLibMap[config.BuildType];
|
||||
foreach (var lib in configLibs)
|
||||
{
|
||||
argsList.Add($"\"{lib}\"");
|
||||
argsList.Add($"{lib}");
|
||||
}
|
||||
|
||||
// Link Libs
|
||||
foreach(var path in config.LinkLibPaths){
|
||||
argsList.Add($"\"{path}\"");
|
||||
argsList.Add($"{path}");
|
||||
}
|
||||
|
||||
//arch
|
||||
|
@ -126,9 +129,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
//Input Obj file
|
||||
var inputFile = DetermineInputFile(config);
|
||||
argsList.Add($"\"{inputFile}\"");
|
||||
|
||||
this.ArgStr = string.Join(" ", argsList);
|
||||
argsList.Add($"{inputFile}");
|
||||
|
||||
this.Args = argsList;
|
||||
}
|
||||
|
||||
private int InvokeLinker()
|
||||
|
@ -136,7 +139,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
|
||||
|
||||
var result = Command.Create(linkerPath, ArgStr)
|
||||
var result = Command.Create(linkerPath, Args.ToArray())
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-*",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23704",
|
||||
"Microsoft.DotNet.AppDep":"1.0.4-*"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
// Need CoreRT Framework published to nuget
|
||||
|
||||
// Do Native Compilation
|
||||
var result = Command.Create("dotnet-compile-native", $"--rsp \"{rsp}\"")
|
||||
var result = Command.Create("dotnet-compile-native", new string[] { "--rsp", $"{rsp}" })
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
@ -207,8 +207,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
// Assemble args
|
||||
var compilerArgs = new List<string>()
|
||||
{
|
||||
$"--temp-output:{intermediateOutputPath}",
|
||||
$"--out:{outputName}"
|
||||
$"--temp-output:\"{intermediateOutputPath}\"",
|
||||
$"--out:\"{outputName}\""
|
||||
};
|
||||
|
||||
var compilationOptions = CompilerUtil.ResolveCompilationOptions(context, args.ConfigValue);
|
||||
|
@ -238,10 +238,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
|
||||
}
|
||||
|
||||
compilerArgs.AddRange(dependency.SourceReferences);
|
||||
compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"\"{s}\""));
|
||||
}
|
||||
|
||||
compilerArgs.AddRange(references.Select(r => $"--reference:{r}"));
|
||||
compilerArgs.AddRange(references.Select(r => $"--reference:\"{r}\""));
|
||||
|
||||
if (compilationOptions.PreserveCompilationContext == true)
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
writer.Write(dependencyContext, fileStream);
|
||||
}
|
||||
|
||||
compilerArgs.Add($"--resource:\"{depsJsonFile}\",{context.ProjectFile.Name}.deps.json");
|
||||
compilerArgs.Add($"--resource:\"{depsJsonFile},{context.ProjectFile.Name}.deps.json\"");
|
||||
|
||||
var refsFolder = Path.Combine(outputPath, "refs");
|
||||
if (Directory.Exists(refsFolder))
|
||||
|
@ -298,7 +298,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
};
|
||||
RunScripts(context, ScriptNames.PreCompile, contextVariables);
|
||||
|
||||
var result = Command.Create($"dotnet-compile-{compilerName}", $"@\"{rsp}\"")
|
||||
var result = Command.Create($"dotnet-compile-{compilerName}", new string[] {"@" + $"{rsp}" })
|
||||
.OnErrorLine(line =>
|
||||
{
|
||||
var diagnostic = ParseDiagnostic(context.ProjectDirectory, line);
|
||||
|
@ -423,7 +423,14 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
{
|
||||
var result =
|
||||
Command.Create("dotnet-resgen",
|
||||
$"\"{resgenFile.InputFile}\" -o \"{resgenFile.OutputFile}\" -v \"{project.Version.Version}\"")
|
||||
new string[]
|
||||
{
|
||||
$"{resgenFile.InputFile}",
|
||||
"-o",
|
||||
$"{resgenFile.OutputFile}",
|
||||
"-v",
|
||||
$"{project.Version.Version}"
|
||||
})
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
@ -433,11 +440,11 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
return false;
|
||||
}
|
||||
|
||||
compilerArgs.Add($"--resource:\"{resgenFile.OutputFile}\",{Path.GetFileName(resgenFile.MetadataName)}");
|
||||
compilerArgs.Add($"--resource:\"{resgenFile.OutputFile},{Path.GetFileName(resgenFile.MetadataName)}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
compilerArgs.Add($"--resource:\"{resgenFile.InputFile}\",{Path.GetFileName(resgenFile.MetadataName)}");
|
||||
compilerArgs.Add($"--resource:\"{resgenFile.InputFile},{Path.GetFileName(resgenFile.MetadataName)}\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Pack
|
||||
{
|
||||
|
@ -39,22 +40,25 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
|
||||
if (_project.Files.SourceFiles.Any())
|
||||
{
|
||||
var argsBuilder = new StringBuilder();
|
||||
argsBuilder.Append($"--configuration {_configuration}");
|
||||
var argsBuilder = new List<string>();
|
||||
argsBuilder.Add("--configuration");
|
||||
argsBuilder.Add($"{_configuration}");
|
||||
|
||||
if (_artifactPathsCalculator.PackageOutputPathSet)
|
||||
{
|
||||
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageOutputPathParameter}\"");
|
||||
argsBuilder.Add("--output");
|
||||
argsBuilder.Add($"{_artifactPathsCalculator.PackageOutputPathParameter}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_intermediateOutputPath))
|
||||
{
|
||||
argsBuilder.Append($" --temp-output \"{_intermediateOutputPath}\"");
|
||||
argsBuilder.Add("--temp-output");
|
||||
argsBuilder.Add($"{_intermediateOutputPath}");
|
||||
}
|
||||
|
||||
argsBuilder.Append($" \"{_project.ProjectFilePath}\"");
|
||||
argsBuilder.Add($"{_project.ProjectFilePath}");
|
||||
|
||||
var result = Command.Create("dotnet-build", argsBuilder.ToString())
|
||||
var result = Command.Create("dotnet-build", argsBuilder)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
|
|
|
@ -102,12 +102,17 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
}
|
||||
|
||||
// Compile the project (and transitively, all it's dependencies)
|
||||
var result = Command.Create("dotnet-build",
|
||||
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
|
||||
$"--output \"{outputPathCalculator.BaseCompilationOutputPath}\" " +
|
||||
$"--configuration \"{configuration}\" " +
|
||||
"--no-host " +
|
||||
$"\"{context.ProjectFile.ProjectDirectory}\"")
|
||||
var result = Command.Create("dotnet-build",
|
||||
new string[] {
|
||||
"--framework",
|
||||
$"{context.TargetFramework.DotNetFrameworkName}",
|
||||
"--output",
|
||||
$"{outputPathCalculator.BaseCompilationOutputPath}",
|
||||
"--configuration",
|
||||
$"{configuration}",
|
||||
"--no-host",
|
||||
$"{context.ProjectFile.ProjectDirectory}"
|
||||
})
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
|
@ -60,10 +59,21 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
|
|||
Reporter.Output.WriteLine($"Compiling {projectContext.RootProject.Identity.Name.Yellow()} for {projectContext.TargetFramework.DotNetFrameworkName.Yellow()} to use with the {"C# REPL".Yellow()} environment.");
|
||||
|
||||
// --temp-output is actually the intermediate output folder and can be the same as --output for our temporary compilation (`dotnet run` can be seen doing the same)
|
||||
return Command.Create($"dotnet-build", $"--output \"{tempOutputDir}\" --temp-output \"{tempOutputDir}\" --framework \"{projectContext.TargetFramework}\" --configuration \"{configuration}\" \"{projectContext.ProjectDirectory}\"")
|
||||
.ForwardStdOut(onlyIfVerbose: true)
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
return Command.Create($"dotnet-build", new []
|
||||
{
|
||||
$"--output",
|
||||
$"{tempOutputDir}",
|
||||
$"--temp-output",
|
||||
$"{tempOutputDir}",
|
||||
$"--framework",
|
||||
$"{projectContext.TargetFramework}",
|
||||
$"--configuration",
|
||||
$"{configuration}",
|
||||
$"{projectContext.ProjectDirectory}"
|
||||
})
|
||||
.ForwardStdOut(onlyIfVerbose: true)
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration)
|
||||
|
@ -148,7 +158,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
|
|||
}
|
||||
|
||||
string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir);
|
||||
csiArgs.Add($"@\"{responseFile}\"");
|
||||
csiArgs.Add($"@{responseFile}");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(script) && !remainingArguments.Any())
|
||||
|
|
|
@ -90,7 +90,18 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
var tempDir = Path.Combine(_context.ProjectDirectory, "bin", ".dotnetrun", Guid.NewGuid().ToString("N"));
|
||||
|
||||
// Compile to that directory
|
||||
var result = Command.Create($"dotnet-build", $"--output \"{tempDir}\" --temp-output \"{tempDir}\" --framework \"{_context.TargetFramework}\" --configuration \"{Configuration}\" {_context.ProjectFile.ProjectDirectory}")
|
||||
var result = Command.Create($"dotnet-build", new []
|
||||
{
|
||||
$"--output",
|
||||
$"{tempDir}",
|
||||
$"--temp-output",
|
||||
$"{tempDir}",
|
||||
$"--framework",
|
||||
$"{_context.TargetFramework}",
|
||||
$"--configuration",
|
||||
$"{Configuration}",
|
||||
$"{_context.ProjectFile.ProjectDirectory}"
|
||||
})
|
||||
.ForwardStdOut(onlyIfVerbose: true)
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
|
@ -134,7 +145,7 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
}
|
||||
}
|
||||
|
||||
result = Command.Create(outputName, string.Join(" ", _args))
|
||||
result = Command.Create(outputName, _args)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.EnvironmentVariable("DOTNET_HOME", runtime)
|
||||
|
@ -151,7 +162,7 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
|
||||
private static int RunInteractive(string scriptName)
|
||||
{
|
||||
var command = Command.Create($"dotnet-repl-csi", scriptName)
|
||||
var command = Command.Create($"dotnet-repl-csi", new [] {scriptName})
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr();
|
||||
var result = command.Execute();
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"System.Diagnostics.TextWriterTraceListener": "4.0.0-rc2-23704",
|
||||
"System.Diagnostics.TraceSource": "4.0.0-rc2-23704",
|
||||
|
||||
"Microsoft.NETCore.ConsoleHost": "1.0.0-rc2-23616",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23616",
|
||||
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.Extensions.Testing.Abstractions": "1.0.0-*",
|
||||
"Microsoft.Dnx.Runtime.CommandParsing.Sources": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
|
@ -25,21 +28,14 @@
|
|||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.Testing.Abstractions": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-15935",
|
||||
"Newtonsoft.Json": "7.0.1"
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-16023"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": {"target":"project"},
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-15935",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16011",
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-23704",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704"
|
||||
|
@ -20,7 +20,5 @@
|
|||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace Microsoft.DotNet.Tools.Restore
|
|||
Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'");
|
||||
|
||||
File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"dnxcore50"}, tooldep));
|
||||
NuGet3.Restore(new [] { $"\"{projectPath}\"", "--runtime", $"{DefaultRid}"}.Concat(args), quiet);
|
||||
NuGet3.Restore(new [] { $"{projectPath}", "--runtime", $"{DefaultRid}"}.Concat(args), quiet);
|
||||
}
|
||||
|
||||
private static string GenerateProjectJsonContents(IEnumerable<string> frameworks, LibraryRange tooldep)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-15935",
|
||||
"Microsoft.Extensions.Logging": "1.0.0-rc2-16010",
|
||||
"Newtonsoft.Json": "7.0.1"
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System.Diagnostics;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.DotNet.Tests.ArgumentForwarding
|
||||
{
|
||||
public class ArgumentForwardingTests : TestBase
|
||||
{
|
||||
private static readonly string s_reflectorExeName = "Reflector" + Constants.ExeSuffix;
|
||||
private static readonly string s_reflectorCmdName = "reflector_cmd";
|
||||
|
||||
private string ReflectorPath { get; set; }
|
||||
private string ReflectorCmdPath { get; set; }
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
Console.WriteLine("Dummy Entrypoint.");
|
||||
}
|
||||
|
||||
public ArgumentForwardingTests()
|
||||
{
|
||||
// This test has a dependency on an argument reflector
|
||||
// Make sure it's been binplaced properly
|
||||
FindAndEnsureReflectorPresent();
|
||||
}
|
||||
|
||||
private void FindAndEnsureReflectorPresent()
|
||||
{
|
||||
ReflectorPath = Path.Combine(AppContext.BaseDirectory, s_reflectorExeName);
|
||||
ReflectorCmdPath = Path.Combine(AppContext.BaseDirectory, s_reflectorCmdName);
|
||||
File.Exists(ReflectorPath).Should().BeTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests argument forwarding in Command.Create
|
||||
/// This is a critical scenario for the driver.
|
||||
/// </summary>
|
||||
/// <param name="testUserArgument"></param>
|
||||
[Theory]
|
||||
[InlineData(@"""abc"" d e")]
|
||||
[InlineData(@"""abc"" d e")]
|
||||
[InlineData("\"abc\"\t\td\te")]
|
||||
[InlineData(@"a\\b d""e f""g h")]
|
||||
[InlineData(@"\ \\ \\\")]
|
||||
[InlineData(@"a\""b c d")]
|
||||
[InlineData(@"a\\""b c d")]
|
||||
[InlineData(@"a\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c"" d e")]
|
||||
[InlineData(@"a""b c""d e""f g""h i""j k""l")]
|
||||
[InlineData(@"a b c""def")]
|
||||
[InlineData(@"""\a\"" \\""\\\ b c")]
|
||||
[InlineData(@"a\""b \\ cd ""\e f\"" \\""\\\")]
|
||||
public void TestArgumentForwarding(string testUserArgument)
|
||||
{
|
||||
// Get Baseline Argument Evaluation via Reflector
|
||||
var rawEvaluatedArgument = RawEvaluateArgumentString(testUserArgument);
|
||||
|
||||
// Escape and Re-Evaluate the rawEvaluatedArgument
|
||||
var escapedEvaluatedRawArgument = EscapeAndEvaluateArgumentString(rawEvaluatedArgument);
|
||||
|
||||
rawEvaluatedArgument.Length.Should().Be(escapedEvaluatedRawArgument.Length);
|
||||
|
||||
for (int i=0; i<rawEvaluatedArgument.Length; ++i)
|
||||
{
|
||||
var rawArg = rawEvaluatedArgument[i];
|
||||
var escapedArg = escapedEvaluatedRawArgument[i];
|
||||
|
||||
rawArg.Should().Be(escapedArg);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests argument forwarding in Command.Create to a cmd file
|
||||
/// This is a critical scenario for the driver.
|
||||
/// </summary>
|
||||
/// <param name="testUserArgument"></param>
|
||||
[Theory]
|
||||
[InlineData(@"""abc"" d e")]
|
||||
[InlineData(@"""abc"" d e")]
|
||||
[InlineData("\"abc\"\t\td\te")]
|
||||
[InlineData(@"a\\b d""e f""g h")]
|
||||
[InlineData(@"\ \\ \\\")]
|
||||
[InlineData(@"a\""b c d")]
|
||||
[InlineData(@"a\\""b c d")]
|
||||
[InlineData(@"a\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c d")]
|
||||
[InlineData(@"a\\\\""b c"" d e")]
|
||||
[InlineData(@"a""b c""d e""f g""h i""j k""l")]
|
||||
[InlineData(@"a b c""def")]
|
||||
[InlineData(@"""\a\"" \\""\\\ b c")]
|
||||
[InlineData(@"a\""b \\ cd ""\e f\"" \\""\\\")]
|
||||
public void TestArgumentForwardingCmd(string testUserArgument)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Baseline Argument Evaluation via Reflector
|
||||
// This does not need to be different for cmd because
|
||||
// it only establishes what the string[] args should be
|
||||
var rawEvaluatedArgument = RawEvaluateArgumentString(testUserArgument);
|
||||
|
||||
// Escape and Re-Evaluate the rawEvaluatedArgument
|
||||
var escapedEvaluatedRawArgument = EscapeAndEvaluateArgumentStringCmd(rawEvaluatedArgument);
|
||||
|
||||
try
|
||||
{
|
||||
rawEvaluatedArgument.Length.Should().Be(escapedEvaluatedRawArgument.Length);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("Argument Lists differ in length.");
|
||||
|
||||
var expected = string.Join(",", rawEvaluatedArgument);
|
||||
var actual = string.Join(",", escapedEvaluatedRawArgument);
|
||||
Console.WriteLine($"Expected: {expected}");
|
||||
Console.WriteLine($"Actual: {actual}");
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rawEvaluatedArgument.Length; ++i)
|
||||
{
|
||||
var rawArg = rawEvaluatedArgument[i];
|
||||
var escapedArg = escapedEvaluatedRawArgument[i];
|
||||
|
||||
try
|
||||
{
|
||||
rawArg.Should().Be(escapedArg);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine($"Expected: {rawArg}");
|
||||
Console.WriteLine($"Actual: {escapedArg}");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EscapeAndEvaluateArgumentString returns a representation of string[] args
|
||||
/// when rawEvaluatedArgument is passed as an argument to a process using
|
||||
/// Command.Create(). Ideally this should escape the argument such that
|
||||
/// the output is == rawEvaluatedArgument.
|
||||
/// </summary>
|
||||
/// <param name="rawEvaluatedArgument">A string[] representing string[] args as already evaluated by a process</param>
|
||||
/// <returns></returns>
|
||||
private string[] EscapeAndEvaluateArgumentString(string[] rawEvaluatedArgument)
|
||||
{
|
||||
var commandResult = Command.Create(ReflectorPath, rawEvaluatedArgument)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.Execute();
|
||||
|
||||
commandResult.ExitCode.Should().Be(0);
|
||||
|
||||
return ParseReflectorOutput(commandResult.StdOut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EscapeAndEvaluateArgumentString returns a representation of string[] args
|
||||
/// when rawEvaluatedArgument is passed as an argument to a process using
|
||||
/// Command.Create(). Ideally this should escape the argument such that
|
||||
/// the output is == rawEvaluatedArgument.
|
||||
/// </summary>
|
||||
/// <param name="rawEvaluatedArgument">A string[] representing string[] args as already evaluated by a process</param>
|
||||
/// <returns></returns>
|
||||
private string[] EscapeAndEvaluateArgumentStringCmd(string[] rawEvaluatedArgument)
|
||||
{
|
||||
var cmd = Command.Create(s_reflectorCmdName, rawEvaluatedArgument);
|
||||
var commandResult = cmd
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.Execute();
|
||||
|
||||
Console.WriteLine(commandResult.StdOut);
|
||||
Console.WriteLine(commandResult.StdErr);
|
||||
|
||||
commandResult.ExitCode.Should().Be(0);
|
||||
|
||||
return ParseReflectorCmdOutput(commandResult.StdOut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse the output of the reflector into a string array.
|
||||
/// Reflector output is simply string[] args written to
|
||||
/// one string separated by commas.
|
||||
/// </summary>
|
||||
/// <param name="reflectorOutput"></param>
|
||||
/// <returns></returns>
|
||||
private string[] ParseReflectorOutput(string reflectorOutput)
|
||||
{
|
||||
return reflectorOutput.Split(',');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse the output of the reflector into a string array.
|
||||
/// Reflector output is simply string[] args written to
|
||||
/// one string separated by commas.
|
||||
/// </summary>
|
||||
/// <param name="reflectorOutput"></param>
|
||||
/// <returns></returns>
|
||||
private string[] ParseReflectorCmdOutput(string reflectorOutput)
|
||||
{
|
||||
var args = reflectorOutput.Split(new string[] { "," }, StringSplitOptions.None);
|
||||
args[args.Length-1] = args[args.Length-1].TrimEnd('\r', '\n');
|
||||
|
||||
// To properly pass args to cmd, quotes inside a parameter are doubled
|
||||
// Count them as a single quote for our comparison.
|
||||
for (int i=0; i < args.Length; ++i)
|
||||
{
|
||||
args[i] = args[i].Replace(@"""""", @"""");
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RawEvaluateArgumentString returns a representation of string[] args
|
||||
/// when testUserArgument is provided (unmodified) as arguments to a c#
|
||||
/// process.
|
||||
/// </summary>
|
||||
/// <param name="testUserArgument">A test argument representing what a "user" would provide to a process</param>
|
||||
/// <returns>A string[] representing string[] args with the provided testUserArgument</returns>
|
||||
private string[] RawEvaluateArgumentString(string testUserArgument)
|
||||
{
|
||||
var proc = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = s_reflectorExeName,
|
||||
Arguments = testUserArgument,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
|
||||
proc.Start();
|
||||
proc.WaitForExit();
|
||||
var stdOut = proc.StandardOutput.ReadToEnd();
|
||||
|
||||
Assert.Equal(0, proc.ExitCode);
|
||||
|
||||
return ParseReflectorOutput(stdOut);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>6973e08d-11ec-49dc-82ef-d5effec7c6e9</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Tests.ArgumentForwarding</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>
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library" : "1.0.0-rc2-23714",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23714",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": { "target": "project" },
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
38
test/ArgumentForwardingTests/Reflector/Reflector.cs
Normal file
38
test/ArgumentForwardingTests/Reflector/Reflector.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System.Diagnostics;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.DotNet.Tests.ArgumentForwarding
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
bool first=true;
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write(",");
|
||||
}
|
||||
Console.Write(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
test/ArgumentForwardingTests/Reflector/Reflector.xproj
Normal file
18
test/ArgumentForwardingTests/Reflector/Reflector.xproj
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>6f2e6f25-b43b-495d-9ca5-7f207d1dd604</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Tests.ArgumentForwarding</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>
|
24
test/ArgumentForwardingTests/Reflector/project.json
Normal file
24
test/ArgumentForwardingTests/Reflector/project.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library" : "1.0.0-rc2-23706",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23706",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||
"Microsoft.DotNet.Cli.Utils": { "target": "project" },
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
19
test/ArgumentForwardingTests/Reflector/reflector_cmd.cmd
Normal file
19
test/ArgumentForwardingTests/Reflector/reflector_cmd.cmd
Normal file
|
@ -0,0 +1,19 @@
|
|||
@echo off
|
||||
set ALL_ARGS=
|
||||
set a=%1
|
||||
if not defined a goto :doneSetArgs
|
||||
|
||||
set ALL_ARGS=%~1%
|
||||
shift
|
||||
|
||||
:setArgs
|
||||
set a=%1
|
||||
if not defined a goto :doneSetArgs
|
||||
|
||||
set ALL_ARGS=%ALL_ARGS%,%~1%
|
||||
shift
|
||||
goto setArgs
|
||||
|
||||
:doneSetArgs
|
||||
echo %ALL_ARGS%
|
||||
goto :EOF
|
|
@ -7,7 +7,7 @@
|
|||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>65741cb1-8aee-4c66-8198-10a7ea0e4258</ProjectGuid>
|
||||
<RootNamespace>E2E</RootNamespace>
|
||||
<RootNamespace>Microsoft.DotNet.Tests.EndToEnd</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
{
|
||||
private static readonly string s_expectedOutput = "Hello World!" + Environment.NewLine;
|
||||
private static readonly string s_testdirName = "e2etestroot";
|
||||
private static readonly string s_outputdirName = "testbin";
|
||||
private static readonly string s_outputdirName = "test space/bin";
|
||||
|
||||
private string Rid { get; set; }
|
||||
private string TestDirectory { get; set; }
|
||||
|
@ -51,8 +51,6 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
[Fact]
|
||||
public void TestDotnetIncrementalBuild()
|
||||
{
|
||||
TestSetup();
|
||||
|
||||
// first build
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory);
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
|
|
@ -6,18 +6,20 @@
|
|||
|
||||
"dependencies": {
|
||||
"NETStandard.Library" : "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.TestHost" : "1.0.0-rc2-23704",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": "1.0.0-*"
|
||||
"Microsoft.DotNet.ProjectModel": {"target":"project"},
|
||||
"Microsoft.DotNet.Cli.Utils": {"target":"project"},
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": {"target":"project"}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
},
|
||||
"testRunner":"xunit"
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-151221",
|
||||
"Microsoft.NETCore.ConsoleHost": "1.0.0-23428",
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-23428",
|
||||
"System.Console": "4.0.0-beta-23109"
|
||||
"Microsoft.NETCore.ConsoleHost": "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-rc2-23704",
|
||||
"System.Console": "4.0.0-rc2-23704"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16530",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel.Loader": "1.0.0-*"
|
||||
"Microsoft.DotNet.ProjectModel.Loader": {"target":"project"}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23704",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23706",
|
||||
"Microsoft.DotNet.ProjectModel": {"target":"project"},
|
||||
"Microsoft.DotNet.ProjectModel.Server": {"target":"project"},
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
|
||||
protected static void AssertProjectSkipped(string skippedProject, CommandResult buildResult)
|
||||
{
|
||||
Assert.Contains($"Project {skippedProject} was previoulsy compiled. Skipping compilation.", buildResult.StdOut, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains($"Project {skippedProject} was previously compiled. Skipping compilation.", buildResult.StdOut, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
protected static void AssertProjectCompiled(string rebuiltProject, CommandResult buildResult)
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.TestHost" : "1.0.0-*",
|
||||
"Microsoft.NETCore.TestHost" : "1.0.0-rc2-23704",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.TestHost" : "1.0.0-*",
|
||||
"Microsoft.NETCore.TestHost" : "1.0.0-rc2-23704",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
new object[] { "", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "", "" },
|
||||
new object[] { "", "", "Release", "" },
|
||||
new object[] { "", "", "", "some/dir"},
|
||||
//new object[] { "", "", "", "\"some/dir/with spaces\"" }, // issue - https://github.com/dotnet/cli/issues/525
|
||||
new object[] { "", "", "", "some/dir/with spaces" },
|
||||
new object[] { "dnxcore50", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
|
||||
};
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(982)]
|
||||
public void PublishScriptsRun()
|
||||
{
|
||||
// create unique directories in the 'temp' folder
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-*",
|
||||
"System.Text.RegularExpressions": "4.0.11-*",
|
||||
"NETStandard.Library": "1.0.0-rc2-23706",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23706",
|
||||
"System.Text.RegularExpressions": "4.0.11-rc2-23706",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
return _outputDirectory == string.Empty ?
|
||||
"" :
|
||||
$"-o {_outputDirectory}";
|
||||
$"-o \"{_outputDirectory}\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private string BuildArgs()
|
||||
{
|
||||
return $"{BuildProfile} {ForceIncrementalUnsafe} {_projectPath} {OutputOption} {TempOutputOption} {ConfigurationOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
|
||||
return $"{BuildProfile} {ForceIncrementalUnsafe} \"{_projectPath}\" {OutputOption} {TempOutputOption} {ConfigurationOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
return _outputDirectory == string.Empty ?
|
||||
"" :
|
||||
$"-o {_outputDirectory}";
|
||||
$"-o \"{_outputDirectory}\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private string GetOutputOption()
|
||||
{
|
||||
return string.IsNullOrEmpty(_output) ? "" : $"-o {_output}";
|
||||
return string.IsNullOrEmpty(_output) ? "" : $"-o \"{_output}\"";
|
||||
}
|
||||
|
||||
private string GetConfigOption()
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
return _projectPath == string.Empty ?
|
||||
"" :
|
||||
$"-p {_projectPath}";
|
||||
$"-p \"{_projectPath}\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
get
|
||||
{
|
||||
return _preserveTemporary ?
|
||||
$"-t {_projectPath}" :
|
||||
$"-t \"{_projectPath}\"" :
|
||||
"";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
|
@ -18,24 +20,71 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
public virtual CommandResult Execute(string args = "")
|
||||
{
|
||||
Console.WriteLine($"Executing - {_command} {args}");
|
||||
var commandResult = Command.Create(_command, args)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
var commandPath = _command;
|
||||
if (!Path.IsPathRooted(_command))
|
||||
{
|
||||
_command = Env.GetCommandPath(_command) ??
|
||||
Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, _command);
|
||||
}
|
||||
|
||||
return commandResult;
|
||||
Console.WriteLine($"Executing - {_command} {args}");
|
||||
|
||||
var stdOut = new StreamForwarder();
|
||||
var stdErr = new StreamForwarder();
|
||||
|
||||
stdOut.ForwardTo(write: Reporter.Output.Write, writeLine: Reporter.Output.WriteLine);
|
||||
stdErr.ForwardTo(write: Reporter.Error.Write, writeLine: Reporter.Output.WriteLine);
|
||||
|
||||
return RunProcess(commandPath, args, stdOut, stdErr);
|
||||
}
|
||||
|
||||
public virtual CommandResult ExecuteWithCapturedOutput(string args = "")
|
||||
{
|
||||
Console.WriteLine($"Executing (Captured Output) - {_command} {args}");
|
||||
var commandResult = Command.Create(_command, args)
|
||||
.CaptureStdErr()
|
||||
.CaptureStdOut()
|
||||
.Execute();
|
||||
|
||||
return commandResult;
|
||||
var commandPath = Env.GetCommandPath(_command, ".exe", ".cmd", "") ??
|
||||
Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, _command, ".exe", ".cmd", "");
|
||||
|
||||
var stdOut = new StreamForwarder();
|
||||
var stdErr = new StreamForwarder();
|
||||
|
||||
stdOut.Capture();
|
||||
stdErr.Capture();
|
||||
|
||||
return RunProcess(commandPath, args, stdOut, stdErr);
|
||||
}
|
||||
|
||||
private CommandResult RunProcess(string executable, string args, StreamForwarder stdOut, StreamForwarder stdErr)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = executable,
|
||||
Arguments = args,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = psi
|
||||
};
|
||||
|
||||
process.EnableRaisingEvents = true;
|
||||
process.Start();
|
||||
|
||||
var threadOut = stdOut.BeginRead(process.StandardOutput);
|
||||
var threadErr = stdErr.BeginRead(process.StandardError);
|
||||
|
||||
process.WaitForExit();
|
||||
threadOut.Join();
|
||||
threadErr.Join();
|
||||
|
||||
var result = new CommandResult(
|
||||
process.ExitCode,
|
||||
stdOut.GetCapturedOutput(),
|
||||
stdErr.GetCapturedOutput());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
"description": "Microsoft.DotNet.Tools.Tests.Utilities Class Library",
|
||||
|
||||
"dependencies": {
|
||||
"System.Collections": "4.0.11-*",
|
||||
"System.Collections.Immutable": "1.1.38-*",
|
||||
"System.Linq": "4.0.1-*",
|
||||
"System.Threading": "4.0.11-*",
|
||||
"System.IO.FileSystem": "4.0.1-*",
|
||||
"System.IO": "4.0.11-*",
|
||||
"System.Runtime.InteropServices": "4.0.21-*",
|
||||
"System.Text.RegularExpressions": "4.0.11-*",
|
||||
"System.Collections": "4.0.11-rc2-23714",
|
||||
"System.Collections.Immutable": "1.1.38-rc2-23714",
|
||||
"System.Linq": "4.0.1-rc2-23714",
|
||||
"System.Threading": "4.0.11-rc2-23714",
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23714",
|
||||
"System.IO": "4.0.11-rc2-23714",
|
||||
"System.Runtime.InteropServices": "4.0.21-rc2-23714",
|
||||
"System.Text.RegularExpressions": "4.0.11-rc2-23714",
|
||||
"FluentAssertions": "4.0.0",
|
||||
"xunit": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": {"target":"project"},
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16530"
|
||||
},
|
||||
|
||||
|
@ -23,3 +23,4 @@
|
|||
"dnxcore50": { }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23616",
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"dotnet-hello": { "version": "1.0.0", "target": "package" }
|
||||
},
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"testRunner": "must-be-specified-to-generate-deps",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23616",
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"dotnet-hello": {"version": "1.0.0", "target": "package"}
|
||||
},
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23616"
|
||||
"NETStandard.Library": "1.0.0-rc2-23704"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library" : "1.0.0-rc2-23704",
|
||||
"NETStandard.Library" : "1.0.0-rc2-23706",
|
||||
|
||||
"xunit": "2.1.0",
|
||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-*",
|
||||
"xunit.netcore.extensions": "1.0.0-prerelease-00153",
|
||||
"xunit.runner.utility": "2.1.0",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"TestLibrary": "1.0.0-*",
|
||||
"TestLibrary": { "target":"project"},
|
||||
|
||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23704"
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Console": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*"
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-rc2-23714",
|
||||
"System.IO": "4.0.10-rc2-23714",
|
||||
"System.Console": "4.0.0-rc2-23714",
|
||||
"System.Runtime": "4.0.21-rc2-23714"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
},
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Console": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.21-beta-*"
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-rc2-23714",
|
||||
"System.IO": "4.0.10-rc2-23714",
|
||||
"System.Console": "4.0.0-rc2-23714",
|
||||
"System.Runtime": "4.0.21-rc2-23714"
|
||||
},
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue