Exemple #1
0
        public void Commit(ILogger log)
        {
            if (!Success)
            {
                var name = $"{ProjectName}.nuget.targets";
                var path = Path.Combine(ProjectDirectory, name);

                log.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.Log_GeneratingMsBuildFile, name));
                GenerateMSBuildErrorFile(path);
            }
            else
            {
                // Generate the files as needed
                var targetsName = $"{ProjectName}.nuget.targets";
                var propsName   = $"{ProjectName}.nuget.props";
                var targetsPath = Path.Combine(ProjectDirectory, targetsName);
                var propsPath   = Path.Combine(ProjectDirectory, propsName);

                if (Targets.Any())
                {
                    log.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.Log_GeneratingMsBuildFile, targetsName));

                    GenerateImportsFile(targetsPath, Targets);
                }
                else if (File.Exists(targetsPath))
                {
                    File.Delete(targetsPath);
                }

                if (Props.Any())
                {
                    log.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.Log_GeneratingMsBuildFile, propsName));

                    GenerateImportsFile(propsPath, Props);
                }
                else if (File.Exists(propsPath))
                {
                    File.Delete(propsPath);
                }
            }
        }
        public void Commit(NuGet.Common.ILogger log)
        {
            if (!Success)
            {
                var name = $"{ProjectName}.nuget.targets";
                var path = Path.Combine(ProjectDirectory, name);

                log.LogMinimal(GettextCatalog.GetString("Generating MSBuild file {0}.", name));
                GenerateMSBuildErrorFile(path);
            }
            else
            {
                // Generate the files as needed
                var targetsName = $"{ProjectName}.nuget.targets";
                var propsName   = $"{ProjectName}.nuget.props";
                var targetsPath = Path.Combine(ProjectDirectory, targetsName);
                var propsPath   = Path.Combine(ProjectDirectory, propsName);

                if (Targets.Any())
                {
                    log.LogMinimal(GettextCatalog.GetString("Generating MSBuild file {0}.", targetsName));

                    GenerateImportsFile(targetsPath, Targets);
                }
                else if (File.Exists(targetsPath))
                {
                    File.Delete(targetsPath);
                }

                if (Props.Any())
                {
                    log.LogMinimal(GettextCatalog.GetString("Generating MSBuild file {0}.", propsName));

                    GenerateImportsFile(propsPath, Props);
                }
                else if (File.Exists(propsPath))
                {
                    File.Delete(propsPath);
                }
            }
        }
Exemple #3
0
 public string ToExpr()
 {
     if (IsEnum)
     {
         var sb = new StringBuilder();
         sb.AppendLine("/**");
         sb.Append(" * ");
         sb.AppendLine(Description);
         sb.AppendLine(" */");
         sb.AppendLine($"declare enum {Name} {{");
         sb.Append($"{string.Join("\n\n", Props.Select(p => p.ToEnumExpr()))}");
         sb.Append($"\n}}\n\n");
         return(sb.ToString());
     }
     else
     {
         var superClass = IsCollection ? $"Array<{SuperClass}>" : SuperClass;
         var sb         = new StringBuilder();
         sb.AppendLine("/**");
         sb.Append(" * ");
         sb.AppendLine(Description);
         sb.AppendLine(" */");
         sb.Append($"declare class {Name}");
         sb.Append($"{(!string.IsNullOrWhiteSpace(superClass) ? $" extends {superClass}" : "")} {{\n");
         if (Props.Any())
         {
             sb.AppendJoin("\n\n", Props.Select(p => p.ToClassExpr()));
         }
         if (Props.Any() && Methods.Any())
         {
             sb.Append("\n\n");
         }
         if (Methods.Any())
         {
             sb.AppendJoin("\n\n", Methods.Select(m => m.ToExpr()));
         }
         sb.Append("\n}\n\n");
         return(sb.ToString());
     }
 }