-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix deps.json trimming with xUnit v2 and allow opt-out #49295
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #49248 by fixing the trimming behavior of the deps.json file so that the xunit.core library is never trimmed and by adding an opt-out property for deps.json library trimming.
- Updated tests to verify both trimmed and untrimmed behavior of libraries without assets.
- Modified various MSBuild targets to pass through the new TrimDepsJsonLibrariesWithoutAssets property.
- Extended the dependency context builder to conditionally skip trimming of specified libraries.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs | Updated test to use Theory for both trimming enabled/disabled scenarios and added regression test for xunit.core. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets | Added default property for TrimDepsJsonLibrariesWithoutAssets and passed it to the build process. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets | Passed TrimDepsJsonLibrariesWithoutAssets to the publish process. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DesignerSupport.targets | Ensured TrimDepsJsonLibrariesWithoutAssets is passed in designer support targets. |
src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs | Introduced a new property and chained it into the dependency context builder. |
src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs | Added handling for the new TrimDepsJsonLibrariesWithoutAssets flag with a special case for xunit.core. |
Comments suppressed due to low confidence (1)
src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs:235
- [nitpick] Consider adding a summary comment for the TrimDepsJsonLibrariesWithoutAssets property to clarify its purpose in controlling library trimming behavior.
.WithTrimLibrariesWithoutAssets(TrimDepsJsonLibrariesWithoutAssets)
{ | ||
var testProject = new TestProject() | ||
{ | ||
TargetFrameworks = ToolsetInfo.CurrentTargetFramework | ||
}; | ||
testProject.PackageReferences.Add(new TestPackageReference("Nerdbank.GitVersioning", "3.6.146")); | ||
|
||
if (!trimLibrariesWithoutAssets) | ||
{ | ||
testProject.AdditionalProperties["TrimDepsJsonLibrariesWithoutAssets"] = "False"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using consistent lowercase boolean string representations (e.g., 'false' instead of 'False') to match the casing used in the MSBuild targets.
testProject.AdditionalProperties["TrimDepsJsonLibrariesWithoutAssets"] = "False"; | |
testProject.AdditionalProperties["TrimDepsJsonLibrariesWithoutAssets"] = "false"; |
Copilot uses AI. Check for mistakes.
var lib = unprocessedLibraries.First(); | ||
unprocessedLibraries.Remove(lib); | ||
|
||
if (lib.Library.Name.Equals("xunit.core", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this check "xunit" as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've fixed this.
Fixes #49248
xunit.core
library so it will never be trimmed from deps.json fileTrimDepsJsonLibrariesWithoutAssets
, which can be set to false to disable deps.json library trimming