diff --git a/build/BuildNuGets.csx b/build/BuildNuGets.csx index 217726865c596da3804d7a45c1c7d4856732e338..fad578d31bc168540dad646989a25aa9d8c3875a 100644 --- a/build/BuildNuGets.csx +++ b/build/BuildNuGets.csx @@ -2,18 +2,27 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; -string usage = @"usage: BuildNuGets.csx "; +string usage = @"usage: BuildNuGets.csx "; -if (Args.Length != 2) +if (Args.Count() != 3) { Console.WriteLine(usage); Environment.Exit(1); } -var binDir = Path.GetFullPath(Args[0]); +var csiRoot = AppDomain.CurrentDomain.BaseDirectory; +var slnRoot = Path.GetFullPath(Path.Combine(csiRoot, "../../")); + +// Strip trailing '\' characters because if the path is later passed on the +// command line when surrounded by quotes (in case the path has spaces) some +// utilities will consider the '\"' as an escape sequence for the end quote + +var binDir = Path.GetFullPath(Args[0]).TrimEnd('\\'); var buildVersion = Args[1].Trim(); -var nuspecDirPath = Path.GetFullPath("../../src/NuGet"); +var nuspecDirPath = Path.GetFullPath(Path.Combine(slnRoot, "src/NuGet")); +var outDir = Path.GetFullPath(Args[2]).TrimEnd('\\'); var licenseUrl = @"http://go.microsoft.com/fwlink/?LinkId=529443"; var authors = @"Microsoft"; @@ -21,23 +30,35 @@ var projectURL = @"http://msdn.com/roslyn"; var tags = @"Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Parser Scanner Lexer Emit CodeGeneration Metadata IL Compilation Scripting Syntax Semantics"; var files = Directory.GetFiles(nuspecDirPath, "*.nuspec"); -var procs = new List(files.Length); + +int exit = 0; foreach (var file in files) { var nugetArgs = $@"pack {file} " + $@"-BasePath ""{binDir}"" " + + $@"-OutputDirectory ""{outDir}"" " + "-ExcludeEmptyDirectories " + $@"-prop licenseUrl=""{licenseUrl}"" " + $@"-prop version=""{buildVersion}"" " + $"-prop authors={authors} " + $@"-prop projectURL=""{projectURL}"" " + $@"-prop tags=""{tags}"""; - Console.WriteLine(nugetArgs); - var p = Process.Start(Path.GetFullPath("../../nuget.exe"), nugetArgs); -} + var nugetExePath = Path.GetFullPath(Path.Combine(slnRoot, "nuget.exe")); + var p = new Process(); + p.StartInfo.FileName = nugetExePath; + p.StartInfo.Arguments = nugetArgs; + p.StartInfo.UseShellExecute = false; -foreach (var p in procs) -{ + Console.WriteLine($"Running: nuget.exe {nugetArgs}"); + p.Start(); p.WaitForExit(); + exit = p.ExitCode; + + if (exit != 0) + { + break; + } } + +Environment.Exit(exit);