Exemplo n.º 1
0
        public override int Execute()
        {
            SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(_fileOrDirectory);

            var baseDirectory        = PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory);
            var relativeProjectPaths = _arguments.Select(p => {
                var fullPath = Path.GetFullPath(p);
                return(Path.GetRelativePath(
                           baseDirectory,
                           Directory.Exists(fullPath) ?
                           MsbuildProject.GetProjectFileFromDirectory(fullPath).FullName :
                           fullPath
                           ));
            });

            bool slnChanged = false;

            foreach (var path in relativeProjectPaths)
            {
                slnChanged |= slnFile.RemoveProject(path);
            }

            slnFile.RemoveEmptyConfigurationSections();

            slnFile.RemoveEmptySolutionFolders();

            if (slnChanged)
            {
                slnFile.Write();
            }

            return(0);
        }
Exemplo n.º 2
0
        public override int Execute()
        {
            SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(_fileOrDirectory);

            var relativeProjectPaths = _appliedCommand.Arguments.Select(p =>
                                                                        PathUtility.GetRelativePath(
                                                                            PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory),
                                                                            Path.GetFullPath(p)))
                                       .ToList();

            bool slnChanged = false;

            foreach (var path in relativeProjectPaths)
            {
                slnChanged |= slnFile.RemoveProject(path);
            }

            slnFile.RemoveEmptyConfigurationSections();

            slnFile.RemoveEmptySolutionFolders();

            if (slnChanged)
            {
                slnFile.Write();
            }

            return(0);
        }
Exemplo n.º 3
0
        public override int Run(string fileOrDirectory)
        {
            SlnFile slnFile = SlnFileFactory.CreateFromFileOrDirectory(fileOrDirectory);

            if (RemainingArguments.Count == 0)
            {
                throw new GracefulException(CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove);
            }

            var relativeProjectPaths = RemainingArguments.Select((p) =>
                                                                 PathUtility.GetRelativePath(
                                                                     PathUtility.EnsureTrailingSlash(slnFile.BaseDirectory),
                                                                     Path.GetFullPath(p))).ToList();

            bool slnChanged = false;

            foreach (var path in relativeProjectPaths)
            {
                slnChanged |= slnFile.RemoveProject(path);
            }

            slnFile.RemoveEmptyConfigurationSections();

            slnFile.RemoveEmptySolutionFolders();

            if (slnChanged)
            {
                slnFile.Write();
            }

            return(0);
        }
Exemplo n.º 4
0
        public override void Run()
        {
            if (parameters.Count < 1)
            {
                throw new SlipeException("Please specify the project name, syntax: \nslipe delete-project {project-name} [-server] [-client]");
            }

            if (!options.ContainsKey("y"))
            {
                Console.WriteLine("Are you sure you wish to proceed? This action can not be undone. y/n");
                if (Console.ReadKey().Key != ConsoleKey.Y)
                {
                    return;
                }
            }

            string name = parameters[0];
            string path = "Source/" + name;

            if (targetsModule)
            {
                path = targetModule.path + "/" + path;
            }

            // delete everything
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            foreach (FileInfo file in directoryInfo.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo directory in directoryInfo.GetDirectories())
            {
                directory.Delete(true);
            }
            Directory.Delete(path);

            SlipeConfigCompileTarget target = options.ContainsKey("module") ? targetModule.compileTargets : config.compileTargets;

            target.server.Remove(name);
            target.client.Remove(name);

            string  csProjPath = path + "/" + name + ".csproj";
            SlnFile solution   = new SlnFile("Resource.sln");

            solution.RemoveProject(name, csProjPath);
        }