Skip to content
Permalink
Browse files

Added nuget validation to the build.cake file

Fixes #102
  • Loading branch information...
Dave Humphreys
Dave Humphreys committed Dec 7, 2018
1 parent 7ffcf5e commit 5ce6c4d815b78fa6a169c21896b92753b5f18ead
Showing with 42 additions and 0 deletions.
  1. +42 −0 build.cake
@@ -5,6 +5,7 @@
#addin nuget:?package=Cake.XCode&version=4.0.0
#addin nuget:?package=Newtonsoft.Json&version=9.0.1
#addin nuget:?package=YamlDotNet&version=4.2.1
#addin nuget:?package=Xamarin.Nuget.Validator&version=1.1.1


var TARGET = Argument ("target", Argument ("t", Argument ("Target", "build")));
@@ -283,4 +284,45 @@ Task ("build").Does (() =>
BuildGroups (BUILD_GROUPS, BUILD_NAMES.ToList (), buildTargets, GIT_PATH, GIT_BRANCH, GIT_PREVIOUS_COMMIT, GIT_COMMIT, FORCE_BUILD);
});

Task("nuget-validation")
.Does(()=>
{
//setup validation options
var options = new Xamarin.Nuget.Validator.NugetValidatorOptions()
{
Copyright = "© Microsoft Corporation. All rights reserved.",
Author = "Microsoft",
Owner = "Microsoft",
NeedsProjectUrl = true,
NeedsLicenseUrl = true,
ValidateRequireLicenseAcceptance = true,
ValidPackageNamespace = new [] { "Xamarin", "Mono", "SkiaSharp", "HarfBuzzSharp", "mdoc" },
};

var nupkgFiles = GetFiles ("./**/output/*.nupkg");

Information ("Found ({0}) Nuget's to validate", nupkgFiles.Count ());

foreach (var nupkgFile in nupkgFiles)
{
Information ("Verifiying Metadata of {0}", nupkgFile.GetFilename ());

var result = Xamarin.Nuget.Validator.NugetValidator.Validate(MakeAbsolute(nupkgFile).FullPath, options);

if (!result.Success)
{
Information ("Metadata validation failed for: {0} \n\n", nupkgFile.GetFilename ());
Information (string.Join("\n ", result.ErrorMessages));
throw new Exception ($"Invalid Metadata for: {nupkgFile.GetFilename ()}");

}
else
{
Information ("Metadata validation passed for: {0}", nupkgFile.GetFilename ());
}

}

});

RunTarget (TARGET);

0 comments on commit 5ce6c4d

Please sign in to comment.
You can’t perform that action at this time.