Skip to content

Commit 96d2427

Browse files
authored
Fix for folders with space in it while generating project (dotnet#376)
* support for folders with spaces * added support for paths with space * revert file * change name of var * remove spaces
1 parent 4f9dc40 commit 96d2427

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

src/mlnet/Utilities/Utils.cs

+35-27
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ internal static ColumnInformation GetSanitizedColumnInformation(ColumnInformatio
150150
{
151151
result.TextColumnNames.Add(Sanitize(value));
152152
}
153-
154-
155153
return result;
156154
}
157155

@@ -174,42 +172,52 @@ internal static string FormatCode(string trainProgramCSFileContent)
174172
}
175173

176174

177-
internal static void AddProjectsToSolution(string modelprojectDir,
175+
internal static int AddProjectsToSolution(string modelprojectDir,
178176
string modelProjectName,
179177
string predictProjectDir,
180178
string predictProjectName,
181179
string trainProjectDir,
182180
string trainProjectName,
183181
string solutionName)
184182
{
185-
var proc2 = new System.Diagnostics.Process();
186-
proc2.StartInfo.FileName = @"dotnet";
187-
188-
proc2.StartInfo.Arguments = $"sln {solutionName} add {Path.Combine(trainProjectDir, trainProjectName)} {Path.Combine(predictProjectDir, predictProjectName)} {Path.Combine(modelprojectDir, modelProjectName)}";
189-
proc2.StartInfo.UseShellExecute = false;
190-
proc2.StartInfo.RedirectStandardOutput = true;
191-
proc2.Start();
192-
string outPut2 = proc2.StandardOutput.ReadToEnd();
193-
194-
proc2.WaitForExit();
195-
var exitCode2 = proc2.ExitCode;
196-
proc2.Close();
183+
var proc = new System.Diagnostics.Process();
184+
try
185+
{
186+
proc.StartInfo.FileName = @"dotnet";
187+
proc.StartInfo.Arguments = $"sln \"{solutionName}\" add \"{Path.Combine(trainProjectDir, trainProjectName)}\" \"{Path.Combine(predictProjectDir, predictProjectName)}\" \"{Path.Combine(modelprojectDir, modelProjectName)}\"";
188+
proc.StartInfo.UseShellExecute = false;
189+
proc.StartInfo.RedirectStandardOutput = true;
190+
proc.Start();
191+
string outPut = proc.StandardOutput.ReadToEnd();
192+
proc.WaitForExit();
193+
var exitCode = proc.ExitCode;
194+
return exitCode;
195+
}
196+
finally
197+
{
198+
proc.Close();
199+
}
197200
}
198201

199-
internal static void CreateSolutionFile(string solutionFile, string outputPath)
202+
internal static int CreateSolutionFile(string solutionFile, string outputPath)
200203
{
201204
var proc = new System.Diagnostics.Process();
202-
proc.StartInfo.FileName = @"dotnet";
203-
204-
proc.StartInfo.Arguments = $"new sln --name {solutionFile} --output {outputPath} --force";
205-
proc.StartInfo.UseShellExecute = false;
206-
proc.StartInfo.RedirectStandardOutput = true;
207-
proc.Start();
208-
string outPut = proc.StandardOutput.ReadToEnd();
209-
210-
proc.WaitForExit();
211-
var exitCode = proc.ExitCode;
212-
proc.Close();
205+
try
206+
{
207+
proc.StartInfo.FileName = @"dotnet";
208+
proc.StartInfo.Arguments = $"new sln --name \"{solutionFile}\" --output \"{outputPath}\" --force";
209+
proc.StartInfo.UseShellExecute = false;
210+
proc.StartInfo.RedirectStandardOutput = true;
211+
proc.Start();
212+
string outPut = proc.StandardOutput.ReadToEnd();
213+
proc.WaitForExit();
214+
var exitCode = proc.ExitCode;
215+
return exitCode;
216+
}
217+
finally
218+
{
219+
proc.Close();
220+
}
213221
}
214222
}
215223
}

0 commit comments

Comments
 (0)