Esempio n. 1
0
        public bool Exec(InitCommandOptions options)
        {
            bool ok;

            Toolchain.RequirePackDm(true);
            Toolchain.RequireSubversion(true);

            var pack = new Library.PackDm.PackDm();

            pack.PackConf = options.ConfFile.Text;
            pack.PackInfo = options.PackFile.Text;

            var svn = new Svn();

            ok = pack.Init();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            ok = svn.Ignore("packages");
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            return(true);
        }
Esempio n. 2
0
        public bool Exec(TagCommandOptions options)
        {
            Toolchain.RequirePackDm();
            Toolchain.RequireSubversion();

            if (options.MakeLatest.On)
            {
                return(CreateLatestTag(options));
            }
            else
            {
                return(CreateTag(options));
            }
        }
Esempio n. 3
0
        public bool Exec(CheckoutCommandOptions options)
        {
            Toolchain.RequireSubversion();

            bool ok;

            if (!options.Repository.On)
            {
                return(Prompt.PrintInvalidUsage("A URI do repositório Subversion não foi indicada."));
            }

            var revision = options.Revision.On ? options.Revision.Text : "HEAD";
            var user     = options.User.On ? options.User.Text : Svn.DefaultUser;
            var pass     = options.Pass.On ? options.Pass.Text : Svn.DefaultPass;

            var folder = options.Directory.On ? options.Directory.Text : ".";

            folder = Path.GetFullPath(folder);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            Prompt.PrintInfo("Workcopy: \n" + folder);

            var workcopy = new SvnWorkcopy(folder, user, pass);
            var remote   = new SvnRemote(user, pass);

            var tag = GetTagName(options);

            if (tag == "latest")
            {
                var baseUri  = options.Repository.Text;
                var tagNames = remote.GetTagNames(baseUri, revision);

                var tagName = SemVer.GetMaxVersion(tagNames);
                if (tagName == null)
                {
                    var exists = remote.HasSpecialFolder(baseUri, revision, "trunk");
                    tagName = exists ? "trunk" : "self";
                }

                tag = tagName;
            }

            var uri = GetRepositoryUri(options, tag);

            var workcopyUri = workcopy.GetInfo(Properties.Url);

            if (options.ForceCheckout.On || uri != workcopyUri)
            {
                workcopy.PurgeWorkcopy();

                ok = workcopy.Checkout(uri, revision);
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }
            else
            {
                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Revert();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Update(revision);
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }

            workcopy.ShowInfo();
            Prompt.PrintInfo("Concluído com êxito.");
            return(true);
        }
Esempio n. 4
0
        public bool Exec(BuildCommandOptions options)
        {
            Toolchain.RequireDevenv();
            Toolchain.RequirePackDm();
            Toolchain.RequireSubversion();

            bool ok;

            string[] solutions;

            if (options.Solutions.On)
            {
                solutions = options.Solutions.Items.FindFiles();
            }
            else
            {
                solutions = "*.sln".FindFiles();
            }

            if (!solutions.Any())
            {
                return(Prompt.PrintNothingToBeDone("Nenhuma solução detectada."));
            }

            var pack = new Library.PackDm.PackDm();

            pack.PackConf = options.ConfFile.Text;
            pack.PackInfo = options.PackFile.Text;

            var svn = new Svn();

            ok = pack.Fill();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            ok = svn.Fill();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            // Imprimindo informação de revisao do pack.info e do subverison
            // no console e no arquivo REVISION.txt
            VersionInfo version;
            {
                var revisionFilepath = Path.GetFullPath("REVISION.txt");

                var loader = new ProjectLoader();
                loader.PackConf = options.ConfFile.Text;
                loader.PackInfo = options.PackFile.Text;
                var ret = loader.LoadProjectHeader();
                if (!ret.Ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                var project = ret.Value;
                version = project.Version;

                // imprimindo no console e no arquivo
                Prompt.PrintInfo(version);
                File.WriteAllText(revisionFilepath, version);
            }

            var configuration = options.Configuration.Text ?? "Release|Any CPU";

            foreach (var solution in solutions)
            {
                var solutionFilename = Path.GetFileName(solution);
                var solutionFolder   = Path.GetDirectoryName(solution);

                ok = $"devenv.com {solution.Quote()} /Rebuild {configuration.Quote()}".Run();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }

            // O packDm usa a máscara para substituir partes da versao
            var versionMask = $"*.*.*{version.FormattedPreRelease}";

            ok = pack.Pack(versionMask);
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            // Constrói a página HTML com informações de setup.
            // Falhas podem ser ignoradas.
            var title = Path.GetFileName(solutions.First()).Replace(".sln", "");

            MakeSetupPage(title, version);

            return(true);
        }