Share SDK resolution during Pack and Publish discovery#55426
Draft
OvesN wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
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
ReleasePropertyProjectLocatoralready uses properties-only partial evaluation to discoverPackReleaseandPublishRelease. This change keepsProjectEvaluationStage.Propertiesand reuses one short-livedEvaluationContextacross all physical-project evaluations performed by a single discovery operation.The selected policy is
SharedSDKCache. It captures most of the measured benefit without sharing filesystem existence, timestamp, or wildcard-expansion observations.For solutions, the first analyzable project is evaluated in solution order to seed the SDK resolver cache deterministically. The remaining projects continue to evaluate in parallel without an external lock.
Performance
Measurements used:
--no-build --no-restoreMicrosoft.Buildmeter in everydotnetprocessaed14721af3b0a8df860e48e19b554ae5a5db289Microsoft.Build.dllSHA-2560A2C98CC577A07D4E5F4783180CF6C792D33E0C12AC89CF13F8C36CFB5F36FAACounts come from
msbuild.project.evaluations. Durations come frommsbuild.project.evaluation.duration; the counter and histogram count are not added together. Aggregated evaluation durations can exceed wall time because solution projects evaluate in parallel.Pack results
Full
Sharedimproved Pack wall time by another 1,019.16 ms (3.05% relative toSharedSDKCache), but that incremental benefit does not justify sharing filesystem observations.Publish results
Full
Sharedimproved Publish wall time by only another 92.45 ms (0.43% relative toSharedSDKCache).The hidden evaluation count remained unchanged for all three policies, while hidden evaluation duration decreased. Non-hidden MSBuild evaluation remained approximately unchanged.
Correctness
.sln,.slnx, lazy-solution, and physical-project evaluation paths.SharedSDKCache, andSharedprototypes.Sharedcan retain a cached missing import after another evaluation creates the file.SharedSDKCacheobserves the new file and avoids this compatibility boundary.Open correctness concern
CachingSdkResolverServicecaches by(submissionId, sdk.Name). In these standalone discovery evaluations, every project uses the invalid submission ID, so the effective cross-project key is only the SDK name. Requested version, project path, solution path, and other resolver inputs are not included.For example, both projects can reference
Contoso.Sdk/1.0.0, while a custom resolver intentionally usesSdkResolverContext.ProjectFilePath:With isolated evaluation, the locator observes
trueandfalseand reportsNETSDK1197. WithSharedSDKCache, if A resolves first, the cachedContoso.Sdkresult is reused for B:The conflict can therefore disappear. The subsequent real Pack invocation uses a separate resolver cache and can independently choose a different first result. The current first-project seed does not eliminate this for SDK names introduced only by later projects. This concern must be resolved before the PR is made ready for review; one possible follow-up design is an MSBuild policy that shares only successful built-in/default resolver results while keeping workload, NuGet, custom, and failed resolutions project-local.
Virtual/file-based projects
Virtual/file-based project discovery remains unchanged and out of scope. It performs full evaluation because it reads items such as
Compile, and sharing its context would require threading the context through all virtual and referenced-virtual-project evaluations with dedicated behavior coverage.Tests
GivenThatWeWantToTestAMultitargetedSolutionWithPublishReleaseOrPackRelease: 25 passed, including.slnand.slnxconflict coverage.Remaining risk
CachingSdkResolverServicecaches by SDK name, matching MSBuild's existing build-submission behavior. The deterministic first-project seed aligns hidden solution discovery with the subsequent MSBuild invocation's solution-order cache seed, but custom resolvers whose output depends on project path remain inherently sensitive to this existing cache contract.