-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/5.0] Fix AssemblyInformationalAttribute version in coreclr corelib #45876
[release/5.0] Fix AssemblyInformationalAttribute version in coreclr corelib #45876
Conversation
@safern can we add a test for this? Seems like it might be easy to regress. Hopefully the test can correlate somehow when we're expected to be in stable mode and insist that this string is a normal version. |
@@ -25,6 +25,14 @@ | |||
<VersionTxtFile Condition="'$(VersionTxtFile)' == ''">$(ArtifactsObjDir)version.txt</VersionTxtFile> | |||
</PropertyGroup> | |||
|
|||
<PropertyGroup> | |||
<!-- Set the boolean below to true to generate packages with stabilized versions --> | |||
<IsShipping>false</IsShipping> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In libraries this property is set to true for anything except tests. Why is this different in coreclr? Based on the official docs, IsShipping
determines if an asset is...
if it is intended to be delivered to customers via an official channel
Why do we set this to false for coreclr packages then, which are shipping to customers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're marking them as non shipping for servicing releases since we don't want to ship them (publish to nuget). The difference with libraries, is that the libraries packages are selectively built, this are always built. I'm just moving this from one place to another to keep the fix simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thanks for clarifying. Do you know if we have an issue regarding building and publishing packages across the repo the same way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so... @Anipik do you know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no we donot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anipik Do you think it would be worth improving the current situation where packaging and publishing properties differ? If yes, could old file one?
RuntimeInformation.FrameworkDescription gives: 2.1: .NET Core 4.6.29321.03 (borked) |
I thought about it, unfortunately we can't since we run tests on CI and not on official builds. PR/CI even if the build is marked as stable, will always have a version suffix and will never be stable (they will always have |
You could crack open the assembly in a target after it is built and read the AssemblyVersion :D |
I think what @safern was saying was that even if he does this, the -ci version would still be there. One thing we could do here would be to have this test be a msbuild-based test that runs as part of the build as opposed to a unit test, and have that msbuild-based test only run on official builds which would quickly check if the assembly version is correct which you can all do with msbuild (or worst case scenario write a small c# task that makes this check) |
That's what I was trying to express. Don't validate as part of a managed xunit that which we don't run as part of the official build but instead validate as part of a post-build target which would error out if the AssemblyVersion isn't the expected one. Condition that target so that it only runs when it should. |
That's a good idea. I was thinking about xunit only 😄 . Will add that. |
I added the MSBuild task and targets to validate that the attribute and version is correct. At first I thought about just doing a simple validation of Second, I started using System.Reflection.MetadataLoadContext, however, since this is an MSBuild task, I was getting:
The only way to do that was to publish instead of build the installer tasks, and that would've been more complicated since you need to specify the core library path and assembly search paths, so if we want to enable this on other projects in the future it would involve more logic. So I decided to go with MetadataReader since you don't need to load any dependencies and you can just get the info needed from there. Let me know if you have any objections or suggestions. I validated by removing my fix and I got an error as expected: C:\repos\runtime\Directory.Build.targets(35,5): error : AssemblyInformationalVersion 5.0.1-dev.20609.11 doesn't match expected version 5.0.1 in: C:\repos\runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\IL\System.Private.CoreLib.dll [C:\repos\runtime\src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj] |
2f8fd06
to
78517da
Compare
@safern can we merge this one if the only thing remaining is tests ? |
78517da
to
7980eef
Compare
I chatted with @ericstj and we decided to keep the change simple and think more about a better way to test it rather than duplicating the logic to calculate the expected value for the version. I will add the test in master and then we can backport the test to 5.0, but let's get this in to fix the issue on 5.0.2. |
Fixes: #45812
I will port this back to master to have it in the same place.
The reason why this was happening is because we added
IsShipping=false
and that causes theInformationalVersion
to include theVersionSuffix
. This was intended to avoid shipping stable packages from coreclr for every servicing release which we wanted to avoid, however this was done on the wrong place as it affectedSystem.Private.CoreLib
.Moving it to
packaging.props
as those properties should only affect packages.Customer Impact
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
API returns wrong version which contains non-stable version suffix.In summary RuntimeInformation.FrameworkDescription gives:
2.1: .NET Core 4.6.29321.03
3.1: .NET Core 3.1.10
5.0.0: .NET 5.0.0
5.0.1: .NET 5.0.1-servicing.20575.16
Testing
Manual testing. Validated that the attribute contains the right version when producing a stable release. (Note, part after + is stripped in the code)
Made sure that package versions are not affected
Risk
Low
Regression
Yes from 5.0.0, introduced when disabling stable packages for coreclr for 5.0.1