Added a PowerShell script to validate NuGet packages#423
Added a PowerShell script to validate NuGet packages#423dakanev-msft wants to merge 1 commit intomainfrom
Conversation
| @@ -0,0 +1,150 @@ | |||
| <# | |||
There was a problem hiding this comment.
Why do we need this script? I think we are running dotnet pack as part of PR build (or we should) so better way might be changing its severity (simular to what ADO does) to fail on missing data or other errors. Also look into https://devblogs.microsoft.com/dotnet/package-validation/
There was a problem hiding this comment.
The publishing to NuGet.org fails if some attributes are missing, e.g. projecturl
I took a look at the package validation link, but I could not find a way to validate if a particular attribute is present in the nuspec file.
I agree that having this validation in the pack step is the preferred way. Do you know how we could use the pack validation to achieve this?
There was a problem hiding this comment.
I assume it's some kind of parameter that ADO pass to dotnet pack task, but github does not, so we can just compare logs.
Also if we need some custom validation I think having MSBuild target in Directories.Build.targets would be much simpler and it would run automatically.
For example:
<Target Name="ValidateNugetPackage" BeforeTargets="pack" Condition="'$(IsPackable)' == 'true'">
<Error Condition="'$(Tags)' == ''" Text="Tags should not be empty" />
...
<Target>
There was a problem hiding this comment.
Initially I tried to add these conditions to Directories.Build.targets but it didn't work because these attributes were always evaluated as empty - for some reason it did not take into account attributes from csproj files.
Added a PowerShell script which can be used as a step in the PR validation pipeline to prevent creating new projects without the required attributes.