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

Show VMR commit hash under dotnet --info for source-built SDKs #3643

Closed
mateusrodrigues opened this issue Sep 29, 2023 · 7 comments · Fixed by dotnet/sdk#41190
Closed

Show VMR commit hash under dotnet --info for source-built SDKs #3643

mateusrodrigues opened this issue Sep 29, 2023 · 7 comments · Fixed by dotnet/sdk#41190
Assignees
Labels
area-product-experience Improvements in the end-user's product experience

Comments

@mateusrodrigues
Copy link
Member

Describe the Problem

Currently, a source-built .NET SDK displays the commit hash of the installer repo -- the one in prereqs/git-info/installer.props -- when you run the command dotnet --info, e.g.

.NET SDK:
 Version:   8.0.100-rc.1.23455.1
 Commit:    e14caf947f

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  23.10
 OS Platform: Linux
 RID:         ubuntu.23.10-x64
 Base Path:   /usr/lib/dotnet/sdk/8.0.100-rc.1.23455.1/
...

Describe the Solution

It would probably make more sense to display the VMR repo commit hash equivalent to the source-tree that generated said SDK when the user types in dotnet --info.

Additional Context

This issue was a result of question #3642.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-build Improvements in source-build's own build process untriaged labels Sep 29, 2023
@MichaelSimons MichaelSimons added area-product-experience Improvements in the end-user's product experience and removed area-build Improvements in source-build's own build process untriaged labels Oct 5, 2023
@ellahathaway ellahathaway self-assigned this Jan 2, 2024
@MichaelSimons
Copy link
Member

MichaelSimons commented Feb 29, 2024

@omajid - Any interest in picking up this item? This would benefit distro maintainers as well as Microsoft with the unified build effort. All builds coming out of the VMR build should be referencing the VMR's commit hash.

CC @mmitche

@omajid omajid self-assigned this Feb 29, 2024
@omajid
Copy link
Member

omajid commented Mar 7, 2024

Is there some way to get the local commit sha inside the VMR? I know in a git repo we can run git rev-parse HEAD and in a tarball scenario, we can use GIT_DIR/HEAD. Is there some existing generic mechanism that abstracts over these?

@MichaelSimons
Copy link
Member

We do fake out some .git files when running in a tarball scenario for source-link. See https://github.com/dotnet/dotnet/blob/main/build.sh#L294.

@omajid
Copy link
Member

omajid commented Mar 8, 2024

Thanks, that build.sh trick is what I meant by GIT_DIR/HEAD above. That seems consistent with https://github.com/dotnet/sourcelink/tree/main/docs#minimal-git-repository-metadata, so I was wondering if there's a SourceLink msbuild task to extract that value.

@omajid
Copy link
Member

omajid commented Mar 9, 2024

It looks like the .version files, are intertwined with the output of dotnet --info, at least for the SDK.

I can get things to look like this, when building the VMR commit 7cf74ae48c8bb032adf0b10cf106938f5692b7a0 with some changes:

$ ./dotnet --info
.NET SDK:
 Version:           9.0.100-preview.3.24157.1
 Commit:            7cf74ae48c
 Workload version:  9.0.100-manifests.4624a33c
 MSBuild version:   17.10.0-preview-24127-03+6f44380e4

Runtime Environment:
 OS Name:     fedora
 OS Version:  39
 OS Platform: Linux
 RID:         fedora.39-x64
 Base Path:   /home/omajid/devel/dotnet/dotnet/dotnet-sdk/sdk/9.0.100-preview.3.24157.1/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      9.0.0-preview.3.24156.25
  Architecture: x64
  Commit:       7cf74ae48c

.NET SDKs installed:
  9.0.100-preview.3.24157.1 [/home/omajid/devel/dotnet/dotnet/dotnet-sdk/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.3.24156.20 [/home/omajid/devel/dotnet/dotnet/dotnet-sdk/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.3.24156.25 [/home/omajid/devel/dotnet/dotnet/dotnet-sdk/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/lib64/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download


$ find -iname '.version' -exec echo {} \; -exec cat {} \;
./shared/Microsoft.NETCore.App/9.0.0-preview.3.24156.25/.version
7cf74ae48c8bb032adf0b10cf106938f5692b7a0
9.0.0-preview.3.24156.25
./shared/Microsoft.AspNetCore.App/9.0.0-preview.3.24156.20/.version
7cf74ae48c8bb032adf0b10cf106938f5692b7a0
9.0.0-preview.3.24156.20
./sdk/9.0.100-preview.3.24157.1/.version
7cf74ae48c8bb032adf0b10cf106938f5692b7a0
9.0.100-preview.3.24157.1
fedora.39-x64
9.0.100-preview.3.24157.1

I have opened PRs to make this change, but please let me know if .version files should be left alone.

omajid added a commit to omajid/dotnet-installer that referenced this issue Mar 9, 2024
This defines a new environment variable `DotNetGitCommitHash` which
contains the commit hash of the VMR. Individual repositories can use this
to find the VMR's commit hash and then embed/use it as appropriate.

Contributes to dotnet/source-build#3643
omajid added a commit to omajid/dotnet-aspnetcore that referenced this issue Mar 9, 2024
This puts the VMR's commit hash, provided by the VMR as the property
DotNetGitCommitHash, in the .version file.

Contributes to dotnet/source-build#3643
omajid added a commit to omajid/dotnet-installer that referenced this issue Mar 9, 2024
This defines a new environment variable `DotNetGitCommitHash` which
contains the commit hash of the VMR. Individual repositories can use this
to find the VMR's commit hash and then embed/use it as appropriate.

It then uses this hash when generating the SDK's .version file, so
dotnet --info shows this as the SDK version.

Contributes to dotnet/source-build#3643
omajid added a commit to omajid/dotnet-runtime that referenced this issue Mar 9, 2024
The VMR defines DotNetGitCommitHash when building runtime. Use that to
populate the .version file and corehost's commit hash. That results in
showing the VMR's commit hash in the `dotnet --info` output.

Contributes to dotnet/source-build#3643
omajid added a commit to omajid/dotnet-installer that referenced this issue Mar 9, 2024
This defines a new environment variable `DotNetGitCommitHash` which
contains the commit hash of the VMR. Individual repositories can use this
to find the VMR's commit hash and then embed/use it as appropriate.

It then uses this hash when generating the SDK's .version file, so
dotnet --info shows this as the SDK version.

Contributes to dotnet/source-build#3643
@omajid
Copy link
Member

omajid commented Mar 9, 2024

Various repos use commit hashes different ways:

  • Used by sourcelink to point to sources
  • Embedded in .version files (aspnetcore, SDK)
  • Embedded in unmanaged binaries
  • Shown in dotnet --info

When building the VMR in .NET 9+, do we want all of them to be the VMR hashes? Is there any reason for any of them to be the per-repo hash?

@omajid
Copy link
Member

omajid commented Mar 10, 2024

On dotnet/installer#18941, @ViktorHofer said:

The VMR's commit will be identical with the sdk's and installer's commit as part of the ongoing work during NET 9. I'm not sure if this is then needed at all

wtgodbe pushed a commit to dotnet/aspnetcore that referenced this issue Mar 12, 2024
This puts the VMR's commit hash, provided by the VMR as the property
DotNetGitCommitHash, in the .version file.

Contributes to dotnet/source-build#3643
omajid added a commit to omajid/dotnet-installer that referenced this issue Apr 22, 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 installer and sdk repos use the VMR's commit hash and
show that in `dotnet --info`.

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

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

Fixes: dotnet/source-build#3643
omajid added a commit to omajid/dotnet-installer that referenced this issue Apr 29, 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 installer and sdk repos use the VMR's commit hash and
show that in `dotnet --info`.

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

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

Fixes: dotnet/source-build#3643
omajid added a commit to omajid/dotnet-sdk that referenced this issue 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-product-experience Improvements in the end-user's product experience
Projects
Status: Done
4 participants