Skip to content

Fix test assets importing repo defaults instead of SDK defaults - #122154

Draft
agocke with Copilot wants to merge 9 commits into
mainfrom
copilot/fix-directory-build-props-import
Draft

Fix test assets importing repo defaults instead of SDK defaults#122154
agocke with Copilot wants to merge 9 commits into
mainfrom
copilot/fix-directory-build-props-import

Conversation

Copilot AI commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Fixes #122153

main PR

Description

Test assets in src/installer/tests/Assets/Projects/ were importing parent Directory.Build.props, inheriting repo-wide build conventions (TreatWarningsAsErrors, LangVersion=preview, analyzers, etc.) instead of using SDK defaults. This made them unrepresentative of normal .NET applications. Additionally, some test projects were using outdated target frameworks (net6.0).

Changes:

  • Removed the parent Directory.Build.props import statement (without explicitly setting ImportDirectoryBuildProps=false)
  • Define required properties locally: RepoRoot, RepositoryEngineeringDir, ArtifactsDir, NetCoreAppCurrent
  • NetCoreAppCurrent is set as the target framework property for all test assets
  • Updated all 22 test asset projects to use $(NetCoreAppCurrent) instead of hardcoded target frameworks
  • Retain existing build configuration: OutputPath, UseLocalTargetingRuntimePack

Test assets now use SDK defaults (e.g., TreatWarningsAsErrors=false, LangVersion=14.0) and consistently target net10.0 while maintaining ability to target locally built runtime via Directory.Build.targets.

Customer Impact

N/A - Internal test infrastructure only.

Regression

No - this improves test asset fidelity to real-world applications.

Testing

Verified multiple test asset projects build successfully with SDK defaults instead of repo defaults. All test projects now correctly target net10.0 through the NetCoreAppCurrent property.

Risk

Low. Changes isolated to test asset build configuration. Does not affect production code or shipping artifacts.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>src/installer/tests/Assets/Projects/Directory.Build.props shouldn't import parent props</issue_title>
<issue_description>These are test assets and shouldn't pull the repo defaults, but instead should use the SDK defaults.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 3, 2025 19:57
These test assets should use SDK defaults instead of repo defaults.
- Set ImportDirectoryBuildProps=false to prevent automatic parent import
- Define necessary properties locally (NetCoreAppCurrent, paths, etc.)
- Keep Directory.Build.targets imports for local runtime targeting

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
@agocke

agocke commented Dec 3, 2025

Copy link
Copy Markdown
Member

@copilot some of these tests are failing because they reference old target frameworks (.NET 6). Can you please define a TestTfm property in the props file and ensure that all projects use the TestTfm?

@agocke agocke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot please address comments

<PropertyGroup>
<!-- Prevent automatic import of parent Directory.Build.props to avoid pulling in repo defaults.
These are test assets and should use SDK defaults instead. -->
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't necessary, just avoiding the import is enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in commit 5a37deb.

<PropertyGroup>
<!-- This should match NetCoreAppCurrentVersion in the repo root Directory.Build.props -->
<NetCoreAppCurrentVersion>10.0</NetCoreAppCurrentVersion>
<NetCoreAppCurrent>net$(NetCoreAppCurrentVersion)</NetCoreAppCurrent>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be the testtfm, actually

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit 5a37deb. TestTfm is now the primary property with NetCoreAppCurrent as an alias.

- Added TestTfm property to Directory.Build.props (set to NetCoreAppCurrent)
- Updated all test asset projects to use $(TestTfm) instead of $(NetCoreAppCurrent) or hardcoded target frameworks
- This fixes the issue where SelfContained.csproj was using outdated net6.0 target framework

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>

Copilot AI commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@copilot some of these tests are failing because they reference old target frameworks (.NET 6). Can you please define a TestTfm property in the props file and ensure that all projects use the TestTf...

Done in commit 9dfe47a. Added TestTfm property to Directory.Build.props and updated all 22 test asset projects to use $(TestTfm) instead of $(NetCoreAppCurrent) or hardcoded target frameworks like net6.0.

- Remove unnecessary ImportDirectoryBuildProps=false setting
- Make TestTfm the primary property, with NetCoreAppCurrent as an alias
- Simplify property definitions per code review feedback

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>

Copilot AI commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please address comments

Comments addressed in commit 5a37deb.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot NetCoreAppCurrent was a fine name, actually. Let's keep it and set that variable in Directory.Build.props.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit f6d3163. NetCoreAppCurrent is now the primary property, and all 22 test projects use it.

- Removed TestTfm property from Directory.Build.props
- NetCoreAppCurrent is now the primary target framework property
- Updated all 22 test asset projects to use $(NetCoreAppCurrent)

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI requested a review from agocke December 5, 2025 04:39
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@jkotas
jkotas deleted the copilot/fix-directory-build-props-import branch January 24, 2026 03:55
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 23, 2026
@agocke
agocke restored the copilot/fix-directory-build-props-import branch April 14, 2026 18:09
@agocke agocke reopened this Apr 14, 2026
<!-- Define the target framework version these test assets should build against -->
<PropertyGroup>
<!-- This should match NetCoreAppCurrentVersion in the repo root Directory.Build.props -->
<NetCoreAppCurrentVersion>10.0</NetCoreAppCurrentVersion>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot This value is out of sync now. Maybe we should pull in eng/Versions.props and define it based on that, similar to what System.Net StressTests do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the latest commit. The Directory.Build.props now imports eng/Versions.props and derives NetCoreAppCurrentVersion from $(MajorVersion).$(MinorVersion), the same approach used by System.Net StressTests. The value now resolves to net11.0 automatically.

…rdcoding

Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 21:36

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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI requested a review from elinor-fung July 24, 2026 21:37
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.

src/installer/tests/Assets/Projects/Directory.Build.props shouldn't import parent props

4 participants