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

Hide ephemeral ProjectRootElements from import enumerations #11474

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.13.17</VersionPrefix>
<VersionPrefix>17.13.18</VersionPrefix>
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.12.6</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
Expand Down
1 change: 1 addition & 0 deletions src/Build.UnitTests/Evaluation/Preprocessor_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ This import was added implicitly because the Project element's Sdk attribute spe
}

[Fact]
[ActiveIssue("https://github.com/dotnet/msbuild/issues/11498")]
public void SdkResolverItemsAndPropertiesAreInPreprocessedOutput()
{
using (TestEnvironment env = TestEnvironment.Create())
Expand Down
2 changes: 2 additions & 0 deletions src/Build/Construction/ProjectRootElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ public override string Condition
/// </summary>
public ICollection<ProjectImportElement> Imports => new ReadOnlyCollection<ProjectImportElement>(GetAllChildrenOfType<ProjectImportElement>());

internal bool IsEphemeral => _isEphemeral;

/// <summary>
/// Get a read-only collection of the child property groups, if any.
/// Does not include any that may not be at the root, i.e. inside Choose elements.
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Definition/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ public override IList<ResolvedImport> Imports

foreach (ResolvedImport import in _data.ImportClosure)
{
if (import.ImportingElement != null) // Exclude outer project itself
if (import.ImportingElement != null && !import.ImportedProject.IsEphemeral) // Exclude outer project itself and SDK-resolver synthesized imports
{
imports.Add(import);
}
Expand All @@ -2280,7 +2280,7 @@ public override IList<ResolvedImport> ImportsIncludingDuplicates

foreach (var import in _data.ImportClosureWithDuplicates)
{
if (import.ImportingElement != null) // Exclude outer project itself
if (import.ImportingElement != null && !import.ImportedProject.IsEphemeral) // Exclude outer project itself and SDK-resolver synthesized imports
{
imports.Add(import);
}
Expand Down
Loading