Skip to content

Conversation

@dakanev-msft
Copy link
Contributor

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.

@dakanev-msft dakanev-msft requested a review from a team as a code owner October 14, 2021 14:39
@@ -0,0 +1,150 @@
<#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

@AndreyTretyak AndreyTretyak Oct 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants