Exemplo n.º 1
0
        protected override int Execute()
        {
            ConsoleWriter.WriteProgressWithoutSave("self-update");
            Helper.SaveLastUpdateTime();

            try
            {
                InstallPowerShell();
                InstallClinkScript();
                InstallBashScript();

                CreateRunners();
                AddInstallToPath();
            }
            catch (Exception exception)
            {
                Log.Error("Fail to install cement", exception);
                ConsoleWriter.WriteError("Fail to install cement: " + exception);
            }

            var server = CementSettings.Get().CementServer;

            Log.Info($"Cement server: {server}");
            var updater = server == null
                ? (ICementUpdater) new CementFromGitHubUpdater(Log)
                : (ICementUpdater) new CementFromServerUpdater(server, branch, Log);

            return(UpdateBinary(updater));
        }
Exemplo n.º 2
0
        protected override int Execute()
        {
            var cmd = CementSettings.Get().UserCommands[arguments[0]];

            Log.Debug("Run command " + arguments[0] + ": '" + cmd + "'");
            if (arguments.Length > 1)
            {
                arguments = arguments.Skip(1).ToArray();
                cmd       = string.Format(cmd, arguments);
            }

            return(Run(cmd));
        }
Exemplo n.º 3
0
        private static void SearchAndSaveBranchInSettings(ref string branch)
        {
            var settings = CementSettings.Get();

            if (branch != null)
            {
                settings.SelfUpdateTreeish = branch;
            }
            else
            {
                branch = settings.SelfUpdateTreeish;
            }
            settings.Save();
        }
Exemplo n.º 4
0
        private static int Run(string[] args)
        {
            var commands = CommandsList.Commands;

            if (commands.ContainsKey(args[0]))
            {
                return(commands[args[0]].Run(args));
            }

            if (CementSettings.Get().UserCommands.ContainsKey(args[0]))
            {
                return(new UserCommand().Run(args));
            }

            ConsoleWriter.WriteError("Bad command: '" + args[0] + "'");
            return(-1);
        }
Exemplo n.º 5
0
        public string DefineCorrectDefaultToolVersion(string toolName, string settingVersion, string defaultVersion)
        {
            var settings = new CementSettings {
                DefaultMsBuildVersion = settingVersion
            };
            var input    = $@"build:
  target: Solution.sln
  configuration: Release
  tool:
    name: {toolName}
";
            var defaults = new BuildData(null, null, new Tool(null, defaultVersion), new List <string>(), string.Empty);

            var parser        = new BuildSectionParser(settings);
            var buildSections = GetBuildSections(input);
            var actual        = parser.ParseConfiguration(buildSections, defaults);

            return(actual?[0].Tool.Version);
        }
Exemplo n.º 6
0
 public BuildSectionParser(CementSettings settings)
 {
     this.settings = settings;
 }
Exemplo n.º 7
0
 public BuildSectionParser() : this(CementSettings.Get())
 {
 }