|
8 | 8 | #addin nuget:?package=Cake.FileHelpers&version=3.1.0 |
9 | 9 | #addin nuget:?package=Cake.Compression&version=0.1.6 |
10 | 10 | #addin nuget:?package=Cake.MonoApiTools&version=3.0.1 |
| 11 | +#addin nuget:?package=Xamarin.Nuget.Validator&version=1.1.1 |
11 | 12 |
|
12 | 13 | // From Cake.Xamarin.Build, dumps out versions of things |
13 | 14 | //LogSystemInfo (); |
@@ -122,6 +123,48 @@ Task("nuget") |
122 | 123 | }); |
123 | 124 | }); |
124 | 125 |
|
| 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 | + |
125 | 168 | Task ("diff") |
126 | 169 | .WithCriteria (!IsRunningOnWindows ()) |
127 | 170 | .IsDependentOn ("merge") |
@@ -275,7 +318,7 @@ Task ("clean") |
275 | 318 | Task ("ci") |
276 | 319 | .IsDependentOn ("ci-setup") |
277 | 320 | .IsDependentOn ("binderate") |
278 | | - .IsDependentOn ("nuget") |
| 321 | + .IsDependentOn ("nuget-validation") |
279 | 322 | .IsDependentOn ("diff"); |
280 | 323 |
|
281 | 324 | RunTarget (TARGET); |
0 commit comments