Example #1
0
 public static string GetTargetFrameworkJsonContents(string content)
 {
     try
     {
         var    document        = JObject.Parse(content);
         string targetFramework = (string)document["frameworks"].First.ToString()
                                  .Replace("\"", "")
                                  .Replace(":", "")
                                  .Replace("{", "")
                                  .Replace("}", "")
                                  .Trim();
         if (String.IsNullOrEmpty(targetFramework))
         {
             // old-style .csproj
             return(string.Empty);
         }
         else
         {
             KuduEventSource.Log.GenericEvent(
                 ServerConfiguration.GetRuntimeSiteName(),
                 string.Format("Dotnet target framework found: {0}", targetFramework),
                 string.Empty,
                 string.Empty,
                 string.Empty,
                 string.Empty);
             return(targetFramework);
         }
     }
     catch (Exception)
     {
         return(string.Empty);
     }
 }
Example #2
0
 public static string GetTargetFrameworkContents(string content)
 {
     try
     {
         XDocument document               = XDocument.Parse(content);
         var       targetFramework        = document.Root.Descendants("TargetFramework");
         var       targetFrameworkElement = targetFramework.FirstOrDefault();
         if (targetFrameworkElement == null || targetFrameworkElement.Value == null)
         {
             // old-style .csproj
             return(string.Empty);
         }
         else
         {
             KuduEventSource.Log.GenericEvent(
                 ServerConfiguration.GetRuntimeSiteName(),
                 $"Dotnet target framework found: {targetFrameworkElement?.Value}",
                 string.Empty,
                 string.Empty,
                 string.Empty,
                 string.Empty);
             return(targetFrameworkElement.Value);
         }
     }
     catch (Exception)
     {
         return(string.Empty);
     }
 }
Example #3
0
        public static void CriticalExecute(string method, Action action, Func <Exception, bool> shouldFailFast = null)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                if (shouldFailFast == null || shouldFailFast(ex))
                {
                    KuduEventSource.Log.KuduException(
                        ServerConfiguration.GetRuntimeSiteName(),
                        method,
                        string.Empty,
                        string.Empty,
                        "Critical execution encounters an exception and will fail fast in 60s",
                        ex.ToString());

                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        Thread.Sleep(60000);
                        System.Environment.FailFast($"Method {method} encounters critical exception {ex}");
                    });

                    throw;
                }
            }
        }