private static void Main(string[] args) { #if DEBUG args = new string[] { "/rewrite", "C:\\Repos\\Default\\Personnel\\Personnel.sln", "--root=Windows\\bin\\" }; #endif if (2 <= args.Length || args.Length > 3 || args[0] == "-h" || args[0] == "/?" || args[0] == "/h" || args[0] != "/rewrite" && args[0] != "/restore") { WriteUsage(); return; } bool rewrite = args[0] == "/rewrite"; var solutionPath = args[1]; var sln = new SlnParser().Parse(new StreamReader(solutionPath)); string buildPath = null; if (args.Length > 2) { if (args[2].StartsWith("--root=")) { buildPath = args[2].Replace("--root=", string.Empty); } } var assemblies = new HashSet <string>(); foreach (var csprojPath in sln.Projects.Select(p => p.Path)) { var directoryName = Path.GetDirectoryName(solutionPath); var fullCsprojPath = Path.Combine(directoryName, csprojPath); var relativePath = MakeRelativePath(Path.GetDirectoryName(fullCsprojPath) + "\\", directoryName + "\\") + buildPath; if (rewrite) { Rewrite(fullCsprojPath, assemblies, relativePath); } else { Restore(fullCsprojPath); } } }
private static void Main(string[] args) { #if DEBUG args = new string[] { "/rewrite", "C:\\Repos\\Default\\Personnel\\Personnel.sln", "--root=Windows\\bin\\" }; #endif if (2 <= args.Length || args.Length>3 || args[0] == "-h" || args[0] == "/?" || args[0] == "/h" || args[0] != "/rewrite" && args[0] != "/restore") { WriteUsage(); return; } bool rewrite = args[0] == "/rewrite"; var solutionPath = args[1]; var sln = new SlnParser().Parse(new StreamReader(solutionPath)); string buildPath = null; if (args.Length > 2) { if (args[2].StartsWith("--root=")) { buildPath = args[2].Replace("--root=", string.Empty); } } var assemblies = new HashSet<string>(); foreach (var csprojPath in sln.Projects.Select(p => p.Path)) { var directoryName = Path.GetDirectoryName(solutionPath); var fullCsprojPath = Path.Combine(directoryName, csprojPath); var relativePath = MakeRelativePath(Path.GetDirectoryName(fullCsprojPath) + "\\", directoryName+"\\") + buildPath; if (rewrite) Rewrite(fullCsprojPath, assemblies, relativePath); else Restore(fullCsprojPath); } }