public override int Run(string fileOrDirectory) { SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(fileOrDirectory); if (RemainingArguments.Count == 0) { throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd); } PathUtility.EnsureAllPathsExist(RemainingArguments, CommonLocalizableStrings.ProjectDoesNotExist); var fullProjectPaths = RemainingArguments.Select((p) => Path.GetFullPath(p)).ToList(); int preAddProjectCount = slnFile.Projects.Count; foreach (var fullProjectPath in fullProjectPaths) { slnFile.AddProject(fullProjectPath); } if (slnFile.Projects.Count > preAddProjectCount) { slnFile.Write(); } return(0); }
public override int Execute() { SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(_fileOrDirectory); if (_appliedCommand.Arguments.Count == 0) { throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd); } PathUtility.EnsureAllPathsExist(_appliedCommand.Arguments, CommonLocalizableStrings.CouldNotFindProjectOrDirectory, true); var fullProjectPaths = _appliedCommand.Arguments.Select(p => { var fullPath = Path.GetFullPath(p); return(Directory.Exists(fullPath) ? MsbuildProject.GetProjectFileFromDirectory(fullPath).FullName : fullPath); }).ToList(); var preAddProjectCount = slnFile.Projects.Count; foreach (var fullProjectPath in fullProjectPaths) { slnFile.AddProject(fullProjectPath); } if (slnFile.Projects.Count > preAddProjectCount) { slnFile.Write(); } return(0); }
public override void Run() { if (parameters.Count < 1) { throw new SlipeException("Please specify the project name, syntax: \nslipe create-project {project-name} [-server] [-client]"); } string name = parameters[0]; string path = "Source/" + name; if (targetsModule) { path = targetModule.path + "/" + path; } string csProjPath = path + "/" + name + ".csproj"; if (Directory.Exists(path)) { throw new SlipeException("A directory with this name already exists."); } Directory.CreateDirectory(path); CsprojFile projectFile = new CsprojFile(csProjPath, name, "netcoreapp3.0"); projectFile.Save(); SlnFile solution = new SlnFile("Resource.sln"); solution.AddProject(name, csProjPath); SlipeConfigCompileTarget target = targetsModule ? targetModule.compileTargets : config.compileTargets; if (options.ContainsKey("server")) { target.server.Add(name); } if (options.ContainsKey("client")) { target.client.Add(name); } }
public override int Execute() { SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(_fileOrDirectory); var arguments = (_parseResult.ValueForArgument <IEnumerable <string> >(SlnAddParser.ProjectPathArgument) ?? Array.Empty <string>()).ToList().AsReadOnly(); if (arguments.Count == 0) { throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd); } PathUtility.EnsureAllPathsExist(arguments, CommonLocalizableStrings.CouldNotFindProjectOrDirectory, true); var fullProjectPaths = arguments.Select(p => { var fullPath = Path.GetFullPath(p); return(Directory.Exists(fullPath) ? MsbuildProject.GetProjectFileFromDirectory(fullPath).FullName : fullPath); }).ToList(); var preAddProjectCount = slnFile.Projects.Count; foreach (var fullProjectPath in fullProjectPaths) { // Identify the intended solution folders var solutionFolders = DetermineSolutionFolder(slnFile, fullProjectPath); slnFile.AddProject(fullProjectPath, solutionFolders); } if (slnFile.Projects.Count > preAddProjectCount) { slnFile.Write(); } return(0); }