Some small tweaks to make development easier

- Added scripts directory to path when using dotnet tool
- Added dotnet-compile and dotnet-restore
This commit is contained in:
David Fowler 2015-10-06 03:10:26 -07:00
parent 0ce00feacc
commit 550dd7f062
7 changed files with 49 additions and 12 deletions

View file

@ -11,4 +11,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50
# Makes development easier
export PATH=$PATH:$DIR
exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Cli" run "$@"

1
scripts/dotnet-compile Executable file
View file

@ -0,0 +1 @@
exec "dnu" "build" "$@"

View file

@ -0,0 +1,8 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=
dnu build %*
exit /b %ERRORLEVEL%
ENDLOCAL

1
scripts/dotnet-restore Executable file
View file

@ -0,0 +1 @@
exec "dnu" "restore" "$@"

View file

@ -0,0 +1,8 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=
dnu restore %*
exit /b %ERRORLEVEL%
ENDLOCAL

View file

@ -2,6 +2,9 @@
SETLOCAL
SET ERRORLEVEL=
REM makes testing easier for now
set PATH=%PATH%;%~dp0
dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Cli run %*
exit /b %ERRORLEVEL%

View file

@ -26,12 +26,7 @@ namespace Microsoft.DotNet.Cli
{
c.Description = "Produce assemblies for the project in given directory";
c.OnExecute(() =>
{
// Temporary!
return Exec("dnu", new[] { "build" });
// Exec("dotnet-compile", c.RemainingArguments);
});
c.OnExecute(() => Exec("dotnet-compile", c.RemainingArguments));
});
app.Command("restore", c =>
@ -54,6 +49,8 @@ namespace Microsoft.DotNet.Cli
c.OnExecute(() => Exec("dotnet-publish", c.RemainingArguments));
});
// TODO: Handle unknown commands
app.OnExecute(() =>
{
@ -61,27 +58,43 @@ namespace Microsoft.DotNet.Cli
return 2;
});
return app.Execute(args);
try
{
return app.Execute(args);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return 1;
}
private static int Exec(string executable, IList<string> remainingArguments)
private static int Exec(string executable, IList<string> args)
{
var comSpec = Environment.GetEnvironmentVariable("ComSpec");
if (!string.IsNullOrEmpty(comSpec))
{
remainingArguments =
args =
new[] { "/C", "\"", executable }
.Concat(remainingArguments)
.Concat(args)
.Concat(new[] { "\"" })
.ToArray();
executable = comSpec;
}
else
{
// Temporary, we're doing this so that redirecting the output works
args = new[] { "bash", "-c", "\"", executable }
.Concat(args.Select(argument => argument.Replace("\"", "\\\"")))
.Concat(new[] { "\"" })
.ToArray();
executable = "/usr/bin/env";
}
var psi = new ProcessStartInfo
{
FileName = executable,
Arguments = string.Join(" ", remainingArguments),
Arguments = string.Join(" ", args),
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,