public IEnumerable <PackLogMessage> Validate(PackageArchiveReader builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            var nuspecReader = builder.NuspecReader;

            if (SampleProjectUrl.Equals(nuspecReader.GetProjectUrl(), StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("ProjectUrl", nuspecReader.GetProjectUrl()));
            }
            if (SampleLicenseUrl.Equals(nuspecReader.GetLicenseUrl(), StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("LicenseUrl", nuspecReader.GetLicenseUrl()));
            }
            if (SampleIconUrl.Equals(nuspecReader.GetIconUrl(), StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("IconUrl", nuspecReader.GetIconUrl()));
            }
            if (SampleTags.Equals(nuspecReader.GetTags()))
            {
                yield return(CreateIssueFor("Tags", SampleTags));
            }
            if (SampleReleaseNotes.Equals(nuspecReader.GetReleaseNotes(), StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("ReleaseNotes", SampleReleaseNotes));
            }
            if (SampleDescription.Equals(nuspecReader.GetDescription(), StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("Description", SampleDescription));
            }

            var dependency = nuspecReader.GetDependencyGroups().SelectMany(d => d.Packages).FirstOrDefault();

            if (dependency != null &&
                dependency.Id.Equals(SampleManifestDependencyId, StringComparison.Ordinal) &&
                dependency.VersionRange != null &&
                dependency.VersionRange.ToString().Equals("[" + SampleManifestDependencyVersion + "]", StringComparison.Ordinal))
            {
                yield return(CreateIssueFor("Dependency", dependency.ToString()));
            }

            if (dependency != null && dependency.VersionRange == VersionRange.All)
            {
                var issue = PackLogMessage.CreateWarning(String.Format(
                                                             CultureInfo.CurrentCulture,
                                                             AnalysisResources.UnspecifiedDependencyVersionWarning,
                                                             dependency.Id),
                                                         NuGetLogCode.NU5112);
                yield return(issue);
            }
        }
Exemplo n.º 2
0
        public IEnumerable <PackLogMessage> Validate(PackageArchiveReader builder)
        {
            var regex        = new Regex(LegacyRegex, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
            var nuspecReader = builder.NuspecReader;

            if (!regex.IsMatch(nuspecReader.GetVersion().ToFullString()))
            {
                yield return(PackLogMessage.CreateWarning(
                                 string.Format(CultureInfo.CurrentCulture, AnalysisResources.LegacyVersionWarning, nuspecReader.GetVersion().ToFullString()),
                                 NuGetLogCode.NU5105));
            }
        }
Exemplo n.º 3
0
 private void AddFileToBuilder(ManifestFile packageFile)
 {
     if (!Files.Any(p => packageFile.Target.Equals(p.Target, StringComparison.CurrentCultureIgnoreCase)))
     {
         Files.Add(packageFile);
     }
     else
     {
         Logger.Log(PackLogMessage.CreateWarning(string.Format(
                                                     CultureInfo.CurrentCulture,
                                                     Strings.FileNotAddedToPackage,
                                                     packageFile.Source,
                                                     packageFile.Target), NuGetLogCode.NU5118));
     }
 }
 public PackagingException(string message, Exception innerException)
     : base(message, innerException)
 {
     _logMessage = PackLogMessage.CreateError(NuGetLogCode.NU5000, message);
 }
 public PackagingException(NuGetLogCode logCode, string message)
     : base(message)
 {
     _logMessage = PackLogMessage.CreateError(logCode, message);
 }
 private static PackLogMessage CreatePackageIssue(string file)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.MisplacedInitScriptWarning, file),
                NuGetLogCode.NU5107));
 }
Exemplo n.º 7
0
 private PackLogMessage CreatePackageIssue(string target)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.InvalidFrameworkWarning, target),
                NuGetLogCode.NU5103));
 }
 private static PackLogMessage CreatePackageIssueForAssembliesOutsideLib(string target)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.AssemblyOutsideLibWarning, target),
                NuGetLogCode.NU5100));
 }
Exemplo n.º 9
0
 public PackagingException(string message)
     : base(message)
 {
     _logMessage = PackLogMessage.CreateError(message, NuGetLogCode.NU5000);
 }
 private static PackLogMessage CreatePackageIssueForUnrecognizedScripts(string target)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.UnrecognizedScriptWarning, target),
                NuGetLogCode.NU5111));
 }
 private static PackLogMessage CreatePackageIssueForMisplacedScript(string target)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.ScriptOutsideToolsWarning, target),
                NuGetLogCode.NU5110));
 }
Exemplo n.º 12
0
 private static PackLogMessage CreatePackageIssueForPlaceholderFile(string target)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.PlaceholderFileInPackageWarning, target),
                NuGetLogCode.NU5109));
 }
 private static PackLogMessage CreateIssueFor(string field, string value)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.DefaultSpecValueWarning, value, field),
                NuGetLogCode.NU5102));
 }
Exemplo n.º 14
0
 private static PackLogMessage CreateIssue(string file)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.WinRTObsoleteWarning, file),
                NuGetLogCode.NU5106));
 }
Exemplo n.º 15
0
 public PackagingException(NuGetLogCode logCode, string message, Exception innerException)
     : base(message, innerException)
 {
     _logMessage = PackLogMessage.CreateError(message, logCode);
 }
 private static PackLogMessage CreatePackageIssueForPrereleaseDependency(string dependency)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.InvalidPrereleaseDependencyWarning, dependency),
                NuGetLogCode.NU5104));
 }
Exemplo n.º 17
0
 private static PackLogMessage CreatePackageIssueForMisplacedContent(string path)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.MisplacedTransformFileWarning, path),
                NuGetLogCode.NU5108));
 }