Skip to content

Commit

Permalink
Added nuget validation to the build.cake file
Browse files Browse the repository at this point in the history
Fixes #102
  • Loading branch information
Dave Humphreys committed Dec 7, 2018
1 parent 7ffcf5e commit 5ce6c4d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand Down Expand Up @@ -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.