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);
            }
        }
        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));
            }
        }
Example #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));
     }
 }
 private static PackLogMessage CreatePackageIssueForPrereleaseDependency(string dependency)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.InvalidPrereleaseDependencyWarning, dependency),
                NuGetLogCode.NU5104));
 }
Example #5
0
 private static PackLogMessage CreateIssue(string file)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.WinRTObsoleteWarning, file),
                NuGetLogCode.NU5106));
 }
 private static PackLogMessage CreatePackageIssue(string file)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.MisplacedInitScriptWarning, file),
                NuGetLogCode.NU5107));
 }
Example #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));
 }
 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));
 }
Example #11
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));
 }
Example #13
0
 private static PackLogMessage CreatePackageIssueForMisplacedContent(string path)
 {
     return(PackLogMessage.CreateWarning(
                String.Format(CultureInfo.CurrentCulture, AnalysisResources.MisplacedTransformFileWarning, path),
                NuGetLogCode.NU5108));
 }