Beispiel #1
0
        public static ShowParentsAnswer GetUsagesResponse(string moduleName, string checkingBranch, string configuration = "*")
        {
            var webClient = new WebClient();
            var str       = webClient.DownloadString($"{CementSettings.Get().CementServer}/api/v1/{moduleName}/deps/{configuration}/{checkingBranch}");

            return(JsonConvert.DeserializeObject <ShowParentsAnswer>(str));
        }
Beispiel #2
0
        public static void KillMsBuild(ILog log)
        {
            if (!CementSettings.Get().KillMsBuild)
            {
                return;
            }

            try
            {
                foreach (var process in Process.GetProcessesByName("MSBuild"))
                {
                    try
                    {
                        process.Kill();
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
Beispiel #3
0
        public static void KillMsBuild(ILogger log)
        {
            if (!CementSettings.Get().KillMsBuild || Rider.IsRunning)
            {
                return;
            }

            try
            {
                foreach (var process in Process.GetProcessesByName("MSBuild"))
                {
                    try
                    {
                        process.Kill();
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }
            catch (Exception e)
            {
                log.LogError(e, e.Message);
            }
        }
Beispiel #4
0
        public static void Save(CementSettings settings)
        {
            var text = JsonConvert.SerializeObject(settings, Formatting.Indented);
            var path = Path.Combine(Helper.GetGlobalCementDirectory(), "settings");

            Helper.CreateFileAndDirectory(path, text);
        }
Beispiel #5
0
        private void AddUserPassword()
        {
            var settings = CementSettings.Get();

            if (settings.UserName == null || settings.EncryptedPassword == null)
            {
                return;
            }

            startInfo.Domain   = settings.Domain ?? Environment.MachineName;
            startInfo.UserName = settings.UserName;
            var decryptedPassword = Helper.Decrypt(settings.EncryptedPassword);

            var password = new SecureString();

            foreach (var c in decryptedPassword)
            {
                password.AppendChar(c);
            }
            startInfo.Password = password;
        }
Beispiel #6
0
 public static IList <Package> GetPackages()
 {
     return(CementSettings.Get().Packages ?? throw new CementException("Packages not specified."));
 }
Beispiel #7
0
 public static IList <Package> GetPackages()
 {
     return(CementSettings.Get().Packages);
 }
Beispiel #8
0
        public string GetNewCommitHash()
        {
            var webClient = new WebClient();

            try
            {
                var infoModel = JsonConvert.DeserializeObject <InfoResponseModel>(webClient.DownloadString($"{CementSettings.Get().CementServer}/api/v1/cement/info/head/" + branch));
                return(infoModel?.CommitHash);
            }
            catch (WebException ex)
            {
                log.LogError("Fail self-update ", ex);
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                {
                    var resp = (HttpWebResponse)ex.Response;
                    if (resp.StatusCode == HttpStatusCode.NotFound) // HTTP 404
                    {
                        ConsoleWriter.WriteError("Failed to look for updates on branch " + branch + ". Server responsed 404");
                        return(null);
                    }
                }
                ConsoleWriter.WriteError("Failed to look for updates on branch " + branch + ": " + ex.Message);
                return(null);
            }
        }
Beispiel #9
0
 public UsagesProvider(ILogger <UsagesProvider> logger, Func <CementSettings> optionsAccessor)
 {
     this.logger    = logger;
     cementSettings = optionsAccessor();
 }