-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Share SDK resolution during Pack and Publish discovery #55426
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
OvesN
merged 7 commits into
dotnet:main
from
OvesN:dev/veronikao/shared-evaluation-context-pack-publish
Jul 29, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d22707
Share SDK resolution during release property discovery
OvesN 1ce7abe
Merge remote-tracking branch 'upstream/main' into dev/veronikao/share…
OvesN 44e429c
Use shared evaluation context for release discovery
OvesN ab473a5
Test shared release discovery caches
OvesN a631d25
Remove unrelated slnx conflict coverage
OvesN 1cd41ca
Focus release discovery cache coverage
OvesN 286af78
Add comment
OvesN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
78 changes: 78 additions & 0 deletions
78
test/dotnet.Tests/CommandTests/Pack/ReleasePropertyProjectLocatorTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.DotNet.Cli; | ||
|
|
||
| namespace Microsoft.DotNet.Pack.Tests; | ||
|
|
||
| [TestClass] | ||
| [DoNotParallelize] | ||
| public class ReleasePropertyProjectLocatorTests : SdkTest | ||
| { | ||
| private string? _disablePublishAndPackRelease; | ||
|
|
||
| [TestInitialize] | ||
| public void ClearReleaseDiscoveryEnvironmentVariables() | ||
| { | ||
| _disablePublishAndPackRelease = Environment.GetEnvironmentVariable(EnvironmentVariableNames.DISABLE_PUBLISH_AND_PACK_RELEASE); | ||
|
|
||
| Environment.SetEnvironmentVariable(EnvironmentVariableNames.DISABLE_PUBLISH_AND_PACK_RELEASE, null); | ||
| } | ||
|
|
||
| [TestCleanup] | ||
| public void RestoreReleaseDiscoveryEnvironmentVariables() | ||
| { | ||
| Environment.SetEnvironmentVariable(EnvironmentVariableNames.DISABLE_PUBLISH_AND_PACK_RELEASE, _disablePublishAndPackRelease); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void EvaluationContextIsNotRetainedBetweenDiscoveryCalls() | ||
| { | ||
| var testDirectory = TestAssetsManager.CreateTestDirectory().Path; | ||
| string projectPath = Path.Combine(testDirectory, "Test.csproj"); | ||
| string propsPath = Path.Combine(testDirectory, "Directory.Build.props"); | ||
|
|
||
| File.WriteAllText(projectPath, """ | ||
| <Project> | ||
| <Import Project="Directory.Build.props" Condition="Exists('Directory.Build.props')" /> | ||
| <PropertyGroup> | ||
| <PackRelease Condition="'$(PackRelease)' == ''">false</PackRelease> | ||
| </PropertyGroup> | ||
| </Project> | ||
| """); | ||
| WritePackRelease(propsPath, value: true); | ||
|
|
||
| var firstResult = DiscoverPackProperties(projectPath); | ||
|
|
||
| Assert.IsNotNull(firstResult); | ||
| Assert.AreEqual("Release", firstResult["Configuration"]); | ||
|
|
||
| File.Delete(propsPath); | ||
|
|
||
| var secondResult = DiscoverPackProperties(projectPath); | ||
|
|
||
| Assert.IsNotNull(secondResult); | ||
| Assert.IsEmpty(secondResult); | ||
| } | ||
|
|
||
| private static IReadOnlyDictionary<string, string>? DiscoverPackProperties(string projectOrSolutionPath) | ||
| { | ||
| var locator = new ReleasePropertyProjectLocator( | ||
| userSpecifiedExplicitMSBuildProperties: null, | ||
| propertyToCheck: "PackRelease", | ||
| commandOptions: new ReleasePropertyProjectLocator.DependentCommandOptions([projectOrSolutionPath])); | ||
|
|
||
| return locator.GetCustomDefaultConfigurationValueIfSpecified(); | ||
| } | ||
|
|
||
| private static void WritePackRelease(string path, bool value) | ||
| { | ||
| File.WriteAllText(path, $""" | ||
| <Project> | ||
| <PropertyGroup> | ||
| <PackRelease>{value.ToString().ToLowerInvariant()}</PackRelease> | ||
| </PropertyGroup> | ||
| </Project> | ||
| """); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.