Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalise how package version isn't stabilized for dev/preview stages #5640

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Generalise how package version isn't stabilized for dev/preview stages
Follow up on #5632
RussKie committed Nov 22, 2024
commit 525bf1bde0b04d0e2d57fbac0cdfa798bdfd3d8c
15 changes: 10 additions & 5 deletions eng/MSBuild/ProjectStaging.targets
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
<!-- Preview packages: do not use stable branding and do not warn about lack of [Experimental] -->
<SuppressFinalPackageVersion Condition="'$(Stage)' == 'preview'">true</SuppressFinalPackageVersion>
<NoWarn Condition="'$(Stage)' == 'preview'">$(NoWarn);LA0003</NoWarn>

<!-- Amend the description based on stage -->
<Description Condition="'$(Stage)' == 'dev'">Experimental package. $(Description)</Description>
<Description Condition="'$(Stage)' == 'obsolete'">Obsolete Package. $(Description)</Description>
</PropertyGroup>

<!-- Produce errors if we don't have all the right properties defined -->
@@ -22,10 +26,11 @@
<Error Condition="'$(MinMutationScore)' != 'n/a' AND ('$(MinMutationScore)' &lt; 50)" Text="MinMutationScore property must be >= 50 for normal stage." />
</Target>

<!-- Amend the description based on stage -->
<PropertyGroup>
<Description Condition="'$(Stage)' == 'dev'">Experimental package. $(Description)</Description>
<Description Condition="'$(Stage)' == 'obsolete'">Obsolete Package. $(Description)</Description>
</PropertyGroup>
<Target Name="_ValidateVersion" AfterTargets="GenerateNuspec" Condition="'$(Stage)' == 'dev' or '$(Stage)' == 'preview'">
<PropertyGroup>
<_ExpectedVersionSuffix>$(_PreReleaseLabel)$(_BuildNumberLabels)</_ExpectedVersionSuffix>
</PropertyGroup>

<Error Condition=" '$(VersionSuffix)' != '$(_ExpectedVersionSuffix)' " Text="Unexpected package version suffix. Expected suffix for '$(Stage)' stage: '$(_ExpectedVersionSuffix)', received: '$(VersionSuffix)'." />
</Target>
</Project>
16 changes: 12 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -8,13 +8,21 @@
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<ValidateBaseline>true</ValidateBaseline>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<!--
When DotNetFinalVersionKind is set to 'release', this branch will produce stable outputs for 'Shipping' packages
-->
<DotNetFinalVersionKind />
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>

<!-- Enabling this rule will cause build failures on undocumented public APIs. -->
<SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591>
</PropertyGroup>

<PropertyGroup>
<!--
Makes it such that the package version won't be stabilized even when the rest of the repo is going stable.
https://github.com/dotnet/arcade/blob/main/Documentation/CorePackages/Versioning.md#package-version
-->
<SuppressFinalPackageVersion />
Copy link
Member

Choose a reason for hiding this comment

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

NIT: No need to unset it here as that is the default already.

Suggested change
<SuppressFinalPackageVersion />

<SuppressFinalPackageVersion Condition="'$(Stage)' == 'dev' or '$(Stage)' == 'preview'">true</SuppressFinalPackageVersion>
</PropertyGroup>
Copy link
Member Author

Choose a reason for hiding this comment

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

Version suffix calculations are performed in Version.BeforeCommonTargets.targets, which too late for the functionality placed in eng/MSBuild/ProjectStaging.targets
Arguably, we could add eng/MSBuild/ProjectStaging.props, but it feels more logical to have versioning-related configurations in one place (which is here).
image

Copy link
Member

Choose a reason for hiding this comment

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

Will Stage be defined this early though?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see it will because you are creating a Directory.Build.props everywhere to make sure you control the order of imports. While that would work, I'd argue that we are probably defeating the point of the benefit of the change. The initial motivation was to simplify things, and reducing 2 lines in projects (setting the stage, and setting suppressFinalVersion) to a single one, but this is instead now making us having to add new files per project, and it also means that now you need to know to look into this file to see if a package is stable or not and also to know what is the stage.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Probably an even more meta question (sorry for having this discussion in your PR) is: do we even really need package stages? What benefit are we getting out of them? if it is literally just that the description has a few other words as a prefix, then perhaps we should just have stable and unstable packages, and adjust the descriptions of packages accordingly. That way, we can go back to having a single property in the package that marks it's "stableness"

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably an even more meta question (sorry for having this discussion in your PR) is: do we even really need package stages? What benefit are we getting out of them? if it is literally just that the description has a few other words as a prefix, then perhaps we should just have stable and unstable packages, and adjust the descriptions of packages accordingly. That way, we can go back to having a single property in the package that marks it's "stableness"

The stages drive the test coverage requirements

<!-- Produce errors if we don't have all the right property values for normal stage -->
<Target Name="_CheckNormalStageProps" Condition="'$(Stage)' == 'normal'" BeforeTargets="Build">
<Error Condition="'$(MinCodeCoverage)' != 'n/a' AND ('$(MinCodeCoverage)' &lt; 75)" Text="MinCodeCoverage property must be >= 75 for normal stage." />
<Error Condition="'$(MinMutationScore)' != 'n/a' AND ('$(MinMutationScore)' &lt; 50)" Text="MinMutationScore property must be >= 50 for normal stage." />
</Target>

Copy link
Member

Choose a reason for hiding this comment

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

Right but that could easily just be controlled without stages, right? You can basically just change that logic to read whether a package is stable or not via supressfinalpackageversion


<!--

These versions should ONLY be updated by automation.
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
the project itself. -->
<PropertyGroup>
<Stage>dev</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
</PropertyGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>preview</Stage>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>preview</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>preview</Stage>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>preview</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>preview</Stage>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>preview</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>preview</Stage>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>preview</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
</PropertyGroup>
10 changes: 10 additions & 0 deletions src/Libraries/Microsoft.Extensions.AI/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>preview</Stage>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>preview</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- In order to get the right package versions for projects that shouldn't stabilize, we need to set this property before
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<Stage>dev</Stage>
<StageDevDiagnosticId>EXTEXP0018</StageDevDiagnosticId>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Multi-level caching implementation building on and extending IDistributedCache</Description>
@@ -24,9 +24,6 @@
</PropertyGroup>

<PropertyGroup>
<Stage>dev</Stage>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<StageDevDiagnosticId>EXTEXP0018</StageDevDiagnosticId>
<MinCodeCoverage>75</MinCodeCoverage>
<MinMutationScore>50</MinMutationScore>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<Stage>dev</Stage>
<StageDevDiagnosticId>EXTEXP0015</StageDevDiagnosticId>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<Stage>dev</Stage>
<StageDevDiagnosticId>EXTEXP0016</StageDevDiagnosticId>
</PropertyGroup>
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
importing the root level Directory.Build.props file. This property should be kept in here, as opposed to moving it to
the project itself. -->
<PropertyGroup>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
<Stage>dev</Stage>
<StageDevDiagnosticId>EXTEXP0017</StageDevDiagnosticId>
</PropertyGroup>