git.properties: support transitive references from shared projects - #1724
Open
bart-vmware wants to merge 2 commits into
Open
git.properties: support transitive references from shared projects#1724bart-vmware wants to merge 2 commits into
git.properties: support transitive references from shared projects#1724bart-vmware wants to merge 2 commits into
Conversation
Contributor
Summary - All Code Coverage (ubuntu-latest)
|
…teeltoe.Management.GitProperties.Build and fake Steeltoe.Management.Endpoint package.
bart-vmware
force-pushed
the
gitproperties-allow-transitive
branch
from
August 2, 2026 02:44
75d6dc4 to
e0d9477
Compare
bart-vmware
marked this pull request as ready for review
August 2, 2026 03:01
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Steeltoe.Management.GitProperties.Buildcan now be referenced from a shared project (like an AspireServiceDefaults) and made transitive, so every host app referencing that shared project gets its owngit.propertiesautomatically — without adding the package to each host app individually. The test suite was also overhauled to consume the package the same way a real application does, most notably by introducing a fakeSteeltoe.Management.Endpointpackage so tests exercise the real auto-detection path instead of bypassing it.Production change
.targetsfile is now packed only intobuildTransitive\(previouslybuild\).PackageReadme.md:git statuson every build, even though commit/branch/tag info comes from the shared cache.ServiceDefaults) withPrivateAssets="none"andGenerateGitProperties=false, so host apps referencing that shared project pick up the transitive reference and generate their owngit.propertiesvia the defaultautosetting, including aServiceDefaults.csprojexample and a caution block about the added per-projectgitcost.Test infrastructure changes
Fake
Steeltoe.Management.EndpointpackageA new
FakeSteeltoeManagementEndpointPackagerbuilds and packs an empty, fakeSteeltoe.Management.Endpointpackage into the same isolated local NuGet feed used forSteeltoe.Management.GitProperties.Build. It's packed once per test session.The default
TestAppnow references both the real packedSteeltoe.Management.GitProperties.Buildpackage and this fakeSteeltoe.Management.Endpointpackage via genuinePackageReferences, and no longer forcesGenerateGitProperties=true. This makes it match the shape of a real Steeltoe host app and exercises the actualauto-detection code path (which looks for aSteeltoe.Management.Endpointreference in the dependency graph) instead of sidestepping it. SeveralAutoDetectionandSharedCachetests were simplified to userepository.TestAppdirectly, or to referenceWorkspace.FakeEndpointPackageReference, instead of building a bespoke dependency/consumer project pair per test.Packing and NuGet isolation
GitPropertiesSourcePackagernowdotnet builds the realSteeltoe.Management.GitProperties.Buildproject directly from its source location in the repository (instead of first copying the source tree and shared build-infrastructure files likeshared.props,stylecop.json,PackageReadme.md, etc. into a temporary directory) and moves the resulting.nupkginto a session-scoped NuGet feed directory.PackGitPropertiesSourceOnceFixture(renamed fromCompileGitPropertiesBuildOnceFixture) creates one session directory per test run, containingfeedandpackagessubdirectories, and packs both the real and fake packages into it once via[assembly: AssemblyFixture].nuget.confignow also pinsglobalPackagesFolderto the session'spackagesdirectory, so package extraction is isolated per test run instead of relying on the machine-wide NuGet cache.Steeltoe.Management.GitProperties.Buildvia a realPackageReferencerestored from that feed. The previous dedicatedPublishPush/NuGetPackageConsumedViaPackageReferenceGeneratesGitPropertiesTest(which built and restored an isolated one-off package/consumer to prove this) was removed since it's now implicit in every other test.Temp-directory handling
ProcessRunnernow redirects theTMP/TEMP/TMPDIRenvironment variables of every spawneddotnetprocess to a session-scoped temp directory. This is a workaround for Stop using the default temp directory and temp file paths dotnet/msbuild#6219, where MSBuild/NuGet processes otherwise leave behind stray directories directly under the machine's real temp folder.tests\<TestClassName>inside the single session directory, rather than each test creating its own top-level directory directly under the machine temp folder..gitdirectories, instead of walking every file in the test directory (includingbin/objoutput), since only files under.gitare ever marked read-only.GitRepositoryAPICollapsed from several narrowly-named, single-purpose methods (
AddProjectAsync,AddDependencyProjectAsync,AddTestAppReferencingAsync,AddPackageConsumerProjectAsync) into two general, composable ones:AddTestAppAsync(name, packageReferences, projectReferences, targetFrameworks)AddTestLibraryAsync(name, generateGitProperties, packageReferences, projectReferences)Both build their project file via the new
ProjectFileBuilder,PackageReference(PackageId,Version,PrivateAssets), andProjectReference(ProjectName) types, replacing hand-rolled, duplicated string interpolation previously spread acrossTestProjectWriter.CloneAsShallowAsync,AddWorktreeAsync,AddSubmoduleAsync, andSimulatePushnow reference theTestAppproject that Git itself already copied into the clone/worktree/submodule/push destination (GetExistingTestApp), instead of regenerating a brand-new test app project there.Other changes
TestProjectWriter.csreduced from ~300 to ~90 lines, now only responsible for writing files for an already-builtProjectFileBuilder(WriteAppProjectAsync,WriteLibraryProjectAsync,WriteFakeGitProjectAsync,WriteNonZeroExitCodeGitProjectAsync,WriteNuGetConfigAsync).GitPropertiesBuildTestBase→GitPropertiesTestBase,GitPropertiesTestWorkspace→TestWorkspace, andPublishPush\→Publishing\.Transitivity\PrivateAssetsControlsPackageReferenceTransitivityTestverifies theServiceDefaultsscenario end-to-end for all threePrivateAssetsvalues (unset/none/all): a host app generatesgit.propertiesonly when the library it references hasPrivateAssetsunset or"none", and the library itself never generates its own.AutoDetectiontests (AutoDetectionGeneratesGitPropertiesWhenConsumingPackageReferencedTest,AutoDetectionExplicitFalseWinsOverDetectedConsumingPackageReferenceTest) that became redundant onceTestAppitself started referencing the fake Endpoint package and using theautodefault — their behavior is now covered incidentally byPropertyContent\GitPropertiesMatchGitOutputTestand by theDiagnostics\*WarnsByDefaultTesttests, respectively.Quality checklist
If your change affects other repositories, such as Documentation and/or Samples, add linked PRs here.