Skip to content

Use the VMR commit hash for dotnet --info #41190

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

Merged
merged 1 commit into from
May 28, 2024

Conversation

omajid
Copy link
Member

@omajid omajid commented May 27, 2024

Remove the logic that overrides the git commit info for each repo. Let each repo infer the VMR's git commit (via sourcelink).

That will let the sdk, runtime, aspnetcore (and other) repos use the VMR's commit hash and show that in dotnet --info.

This works for both when building the VMR directly in a git repository, as well as when building it from a git-archive tarball thanks to sourcelink's support for minimal git metadata [1].

This is a port of dotnet/installer#18941 to dotnet/sdk since the installer was merged into sdk.

[1] https://github.com/dotnet/sourcelink/tree/main/docs#minimal-git-repository-metadata

Fixes: dotnet/source-build#3643

Remove the logic that overrides the git commit info for each repo. Let
each repo infer the VMR's git commit (via sourcelink).

That will let the sdk, runtime, aspnetcore (and other) repos use the
VMR's commit hash and show that in dotnet --info.

This works for both when building the VMR directly in a git repository,
as well as when building it from a git-archive tarball thanks to
sourcelink's support for minimal git metadata [1].

This is a port of dotnet/installer#18941 to
dotnet/sdk since the installer was merged into sdk.

[1] https://github.com/dotnet/sourcelink/tree/main/docs#minimal-git-repository-metadata

Fixes: dotnet/source-build#3643
@omajid omajid requested review from a team as code owners May 27, 2024 19:27
@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels May 27, 2024
@omajid
Copy link
Member Author

omajid commented May 27, 2024

This is a port of dotnet/installer#18941

Please see dotnet/installer#18941 (comment) for the last set of testing I did for this PR. I am happy to do any other testing that might help minimize the risk of this change.

@akoeplinger @MichaelSimons @mmitche @premun @ViktorHofer

@akoeplinger
Copy link
Member

akoeplinger commented May 28, 2024

Looks good to me, I think given the .version files are updated in the shared frameworks we should be good. You could also disassemble the managed .dll's and check the AssemblyInformationalVersionAttribute, we embed the git sha there too (in previews).

This works for both when building the VMR directly in a git repository, as well as when building it from a git-archive tarball thanks to sourcelink's support for minimal git metadata [1].

Do I understand correctly that it won't work with the existing way we publish tarballs since they don't have .git metadata and we need dotnet/source-build#4290 for that?

@omajid
Copy link
Member Author

omajid commented May 28, 2024

Do I understand correctly that it won't work with the existing way we publish tarballs since they don't have .git metadata and we need dotnet/source-build#4290 for that?

Sorry I wasn't clearer.

The short version is that this is all already working. There's nothing further that needs to be done.

The longer version: When building from a tarball, it is required for the user to pass a --release-manifest or --source-version option. That option is used by build.sh to write the minimal git metadata. Then sourcelink uses that automatically anytime it needs to use repository information, including commit hashes. In other words, everything git-related that is needed has already been set up.

dotnet/source-build#4290 only makes the source archive tarballs bit-by-bit identical (that is, sha256sum tarball1.tar.gz tarball2.tar.gz). It isn't related to the actual VMR commit hash (git rev-parse HEAD). The git commit hash is not present in any git-archive tarball, which is why we need that explicit argument in build.sh.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

👍

@MichaelSimons MichaelSimons merged commit 23296a9 into dotnet:main May 28, 2024
36 checks passed
@omajid
Copy link
Member Author

omajid commented Jun 5, 2024

You could also disassemble the managed .dll's and check the AssemblyInformationalVersionAttribute, we embed the git sha there too (in previews).

Just got around to it. I used this as to extract the version attribute: https://gist.github.com/omajid/c82f19c1850ac3349b3c1641fe214c4b

Scanning all the .dll files in dotnet-sdk-bf3357462de7ef82156db43bfc54581d9db88c49 confirms that all the files contain the AssemblyInformationalVersionAttribute including a +ce1e686e7410d1835ff33a4de2e978daa713fa7d.

@akoeplinger
Copy link
Member

Perfect, thanks for the verification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show VMR commit hash under dotnet --info for source-built SDKs
4 participants