Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Dotnet.Script.Tests/ScriptExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ public void ShouldThrowExceptionWhenSdkIsNotSupported()
Assert.StartsWith("The sdk 'Unsupported' is not supported", processResult.StandardError);
}

[Fact]
public void ShouldRespectEnvironmentExitCodeOfTheScript()
{
var processResult = ScriptTestRunner.Default.ExecuteFixture("EnvironmentExitCode", "--no-cache");
Assert.Equal(0xA0, processResult.ExitCode);
}

private static string CreateTestScript(string scriptFolder)
{
string script = @"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Environment.ExitCode = 0xA0;
Console.WriteLine("Hello World");
6 changes: 5 additions & 1 deletion src/Dotnet.Script/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ private static int Wain(string[] args)
};

var fileCommand = new ExecuteScriptCommand(ScriptConsole.Default, logFactory);
return await fileCommand.Run<int, CommandLineScriptGlobals>(fileCommandOptions);
var result = await fileCommand.Run<int, CommandLineScriptGlobals>(fileCommandOptions);
if (Environment.ExitCode != 0) return Environment.ExitCode;

return result;

}
else
{
Expand Down