Skip to content

Define REPO_COMMIT_HASH for singlefilehost - #131441

Open
elinor-fung wants to merge 1 commit into
dotnet:mainfrom
elinor-fung:singlefile-commit-hash
Open

Define REPO_COMMIT_HASH for singlefilehost#131441
elinor-fung wants to merge 1 commit into
dotnet:mainfrom
elinor-fung:singlefile-commit-hash

Conversation

@elinor-fung

@elinor-fung elinor-fung commented Jul 27, 2026

Copy link
Copy Markdown
Member

singlefilehost statically links the hosting components, which use REPO_COMMIT_HASH (in dotnet --info, hostfxr_get_dotnet_environment_info, and tracing). Because it's built as part of coreclr, which never passed the commit hash, it always reported static instead of the real commit.

This plumbs the commit hash into the coreclr native build via SourceRevisionId, the same way corehost.proj does for the rest of the host, so singlefilehost now contains the actual version like dotnet/hostfxr/apphost.

cc @dotnet/appmodel @AaronRobinsonMSFT

Note

This PR description was drafted with the assistance of GitHub Copilot.

The single-file host statically links the hosting components, which use
REPO_COMMIT_HASH (e.g. in 'dotnet --info', hostfxr_get_dotnet_environment_info,
and tracing). It is built as part of coreclr, which never passed the commit
hash, so configure.h.in hardcoded "static" whenever CLR_SINGLE_FILE_HOST_ONLY
was set.

Plumb the commit hash into the coreclr native build via SourceRevisionId the
same way corehost.proj does for the rest of the host, and always define
REPO_COMMIT_HASH from CLI_CMAKE_COMMIT_HASH so singlefilehost reports the real
commit (or N/A when source control queries are disabled).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 759b9702-1ed5-4618-a21a-a4d7d9a4d7d5
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CoreCLR-native build so the statically-linked singlefilehost gets a real repository commit hash (via CMake CLI_CMAKE_COMMIT_HASH) instead of always reporting "static".

Changes:

  • Remove the CLR_SINGLE_FILE_HOST_ONLY preprocessor special-casing in configure.h.in so REPO_COMMIT_HASH always comes from the CMake-provided commit hash value.
  • Pass CLI_CMAKE_COMMIT_HASH into the CoreCLR native CMake configuration using $(SourceRevisionId) (with a fallback), and ensure source-control info initialization runs when SCM queries are enabled.
Show a summary per file
File Description
src/native/corehost/configure.h.in Drops the "static" override so REPO_COMMIT_HASH consistently uses the CMake-substituted commit hash.
src/coreclr/runtime.proj Plumbs SourceRevisionId into CoreCLR’s native CMake args as CLI_CMAKE_COMMIT_HASH and adds SCM initialization to the build dependencies when enabled.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@elinor-fung Sorry, this seems like one of those things that a minor tweak in the build system or an errant MSBuild/CMake change could break. Do we want a test for this?

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants