Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit ac5bf5c

Browse files
authored
Merge pull request #132 from xamarin/dh_NugetValidation28
Added nuget validation to the 28.x branch
2 parents 4e07e30 + fa019cf commit ac5bf5c

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

build.cake

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#addin nuget:?package=Cake.FileHelpers&version=3.1.0
99
#addin nuget:?package=Cake.Compression&version=0.1.6
1010
#addin nuget:?package=Cake.MonoApiTools&version=3.0.1
11+
#addin nuget:?package=Xamarin.Nuget.Validator&version=1.1.1
1112

1213
// From Cake.Xamarin.Build, dumps out versions of things
1314
//LogSystemInfo ();
@@ -122,6 +123,48 @@ Task("nuget")
122123
});
123124
});
124125

126+
Task("nuget-validation")
127+
.IsDependentOn("nuget")
128+
.Does(()=>
129+
{
130+
//setup validation options
131+
var options = new Xamarin.Nuget.Validator.NugetValidatorOptions()
132+
{
133+
Copyright = "© Microsoft Corporation. All rights reserved.",
134+
Author = "Microsoft",
135+
Owner = "Microsoft",
136+
NeedsProjectUrl = true,
137+
NeedsLicenseUrl = true,
138+
ValidateRequireLicenseAcceptance = true,
139+
ValidPackageNamespace = new [] { "Xamarin", "Mono", "SkiaSharp", "HarfBuzzSharp", "mdoc" },
140+
};
141+
142+
var nupkgFiles = GetFiles ("./output/*.nupkg");
143+
144+
Information ("Found ({0}) Nuget's to validate", nupkgFiles.Count ());
145+
146+
foreach (var nupkgFile in nupkgFiles)
147+
{
148+
Information ("Verifiying Metadata of {0}", nupkgFile.GetFilename ());
149+
150+
var result = Xamarin.Nuget.Validator.NugetValidator.Validate(MakeAbsolute(nupkgFile).FullPath, options);
151+
152+
if (!result.Success)
153+
{
154+
Information ("Metadata validation failed for: {0} \n\n", nupkgFile.GetFilename ());
155+
Information (string.Join("\n ", result.ErrorMessages));
156+
throw new Exception ($"Invalid Metadata for: {nupkgFile.GetFilename ()}");
157+
158+
}
159+
else
160+
{
161+
Information ("Metadata validation passed for: {0}", nupkgFile.GetFilename ());
162+
}
163+
164+
}
165+
166+
});
167+
125168
Task ("diff")
126169
.WithCriteria (!IsRunningOnWindows ())
127170
.IsDependentOn ("merge")
@@ -275,7 +318,7 @@ Task ("clean")
275318
Task ("ci")
276319
.IsDependentOn ("ci-setup")
277320
.IsDependentOn ("binderate")
278-
.IsDependentOn ("nuget")
321+
.IsDependentOn ("nuget-validation")
279322
.IsDependentOn ("diff");
280323

281324
RunTarget (TARGET);

0 commit comments

Comments
 (0)