8000 Use quotes around output folder · dotnet-script/dotnet-script@92bcc44 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit 92bcc44

Browse files
committed
Use quotes around output folder
1 parent d862c0d commit 92bcc44

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

src/Dotnet.Script.Core/ScriptPublisher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void CreateExecutable<TReturn, THost>(ScriptContext context, LogFactory l
8585

8686
var commandRunner = new CommandRunner(logFactory);
8787
// todo: may want to add ability to return dotnet.exe errors
88-
var exitcode = commandRunner.Execute("dotnet", $"publish \"{tempProjectPath}\" -c Release -r {runtimeIdentifier} -o {context.WorkingDirectory}");
88+
var exitcode = commandRunner.Execute("dotnet", $"publish \"{tempProjectPath}\" -c Release -r {runtimeIdentifier} -o \"{context.WorkingDirectory}\"");
8989
if (exitcode != 0)
9090
{
9191
throw new Exception($"dotnet publish failed with result '{exitcode}'");

src/Dotnet.Script.Tests/ScriptPublisherTests.cs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,20 @@ public void SimplePublishDllFromCurrentDirectoryTest()
160160
public void SimplePublishDllToOtherFolderTest()
161161
{
162162
using (var workspaceFolder = new DisposableFolder())
163-
using (var publishFolder = new DisposableFolder())
164163
{
165-
var code = @"WriteLine(""hello world"");";
166-
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
167-
File.WriteAllText(mainPath, code);
168-
var publishResult = ScriptTestRunner.Default.Execute($"publish {mainPath} --dll -o {publishFolder.Path}", workspaceFolder.Path);
169-
Assert.Equal(0, publishResult.exitCode);
164+
using (var publishFolder = new DisposableFolder())
165+
{
166+
var code = @"WriteLine(""hello world"");";
167+
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
168+
File.WriteAllText(mainPath, code);
169+
var publishResult = ScriptTestRunner.Default.Execute($"publish {mainPath} --dll -o {publishFolder.Path}", workspaceFolder.Path);
170+
Assert.Equal(0, publishResult.exitCode);
170171

171-
var dllPath = Path.Combine(publishFolder.Path, "main.dll");
172-
var dllRunResult = ScriptTestRunner.Default.Execute($"exec {dllPath}", publishFolder.Path);
172+
var dllPath = Path.Combine(publishFolder.Path, "main.dll");
173+
var dllRunResult = ScriptTestRunner.Default.Execute($"exec {dllPath}", publishFolder.Path);
173174

174-
Assert.Equal(0, dllRunResult.exitCode);
175+
Assert.Equal(0, dllRunResult.exitCode);
176+
}
175177
}
176178
}
177179

@@ -219,7 +221,7 @@ public void ShouldHandleReferencingAssemblyFromScriptFolder()
219221
{
220222
using (var workspaceFolder = new DisposableFolder())
221223
{
222-
ProcessHelper.RunAndCaptureOutput($"dotnet",$" new classlib -n MyCustomLibrary -o {workspaceFolder.Path}");
224+
ProcessHelper.RunAndCaptureOutput($"dotnet", $" new classlib -n MyCustomLibrary -o {workspaceFolder.Path}");
223225
ProcessHelper.RunAndCaptureOutput($"dotnet", $" build -o {workspaceFolder.Path}", workspaceFolder.Path);
224226
var code = $@"#r ""MyCustomLibrary.dll"" {Environment.NewLine} WriteLine(""hello world"");";
225227
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
@@ -231,6 +233,27 @@ public void ShouldHandleReferencingAssemblyFromScriptFolder()
231233
}
232234
}
233235

236+
[Fact]
237+
public void ShouldHandleSpaceInPublishFolder()
238+
{
239+
using (var workspaceFolder = new DisposableFolder())
240+
{
241+
var code = @"WriteLine(""hello world"");";
242+
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
243+
File.WriteAllText(mainPath, code);
244+
245+
var publishResult = ScriptTestRunner.Default.Execute(@"publish main.csx -o ""publish folder""", workspaceFolder.Path);
246+
247+
Assert.Equal(0, publishResult.exitCode);
248+
249+
var exePath = Path.Combine(workspaceFolder.Path, "publish folder", "script");
250+
var executableRunResult = _commandRunner.Execute(exePath);
251+
252+
Assert.Equal(0, executableRunResult);
253+
}
254+
}
255+
256+
234257
private LogFactory GetLogFactory()
235258
{
236259
return TestOutputHelper.CreateTestLogFactory();

0 commit comments

Comments
 (0)
0