Skip to content

Add MSBuild CLI tests to Apex tests - #7494

Merged
zivkan merged 6 commits into
devfrom
dev-zivkan-apex-msbuild-cli-test
Jun 23, 2026
Merged

zivkan merged 6 commits into
devfrom
dev-zivkan-apex-msbuild-cli-test

Conversation

@zivkan

@zivkan zivkan commented Jun 19, 2026

Copy link
Copy Markdown
Member

Bug

Fixes: potential gap in test coverage

Description

When NuGet's restore runs on the command line, MSBuild will load our assemblies in its process space. If it has already loaded some of our dependencies, then those dependencies will not be loaded from NuGet's install directory, and will have been loaded from elsewhere.

Therefore, this test tries to validate that NuGet is compatible with all the assemblies (and their versions) that MSBuild ship in its own bin directory. Primarily Newtonsoft.Json and Microsoft.Extensions.FileSystemGlobbing.

It does this by emulating a C# MSBuild Task that loads assemblies from the MSBuild bin directory, during NuGet's CollectPackageReferences target, and then runs a restore, making sure to exercise code paths that uses Newtonsoft.Json (via NuGet.Protocol and an HTTP feed) and FileSystemGlobbing (via a package that has contentFiles/ with a wildcard in the nuspec metadata). If MSBuild fails to load NuGet's dependencies because it's already loaded a lower version of the same assemblies, then restore will fail.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc. N/A

@zivkan
zivkan requested a review from a team as a code owner June 19, 2026 11:04
@zivkan
zivkan requested review from kartheekp-ms and martinrrm June 19, 2026 11:04
nkolev92
nkolev92 previously approved these changes Jun 19, 2026

@nkolev92 nkolev92 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.

I think the test case is fine in terms of what it's testing, but honestly, I find this incredibly hard to read.

It feels like there's like 50 extra lines of code.

jebriede
jebriede previously approved these changes Jun 23, 2026

@jebriede jebriede 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.

I agree with the feedback @nkolev92 left. Approving with those suggestions.

@zivkan
zivkan dismissed stale reviews from jebriede and nkolev92 via 9802440 June 23, 2026 07:28
@zivkan
zivkan requested review from jebriede and nkolev92 June 23, 2026 07:28
@zivkan
zivkan merged commit 67d6217 into dev Jun 23, 2026
20 of 21 checks passed
@zivkan
zivkan deleted the dev-zivkan-apex-msbuild-cli-test branch June 23, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants