Skip to content

Avoid creating empty deployment directories on .NET Core when no deployment items are used - #7801

Merged
Amaury Levé (Evangelink) merged 3 commits into
mainfrom
copilot/avoid-creating-empty-deployment-folders
Apr 24, 2026
Merged

Avoid creating empty deployment directories on .NET Core when no deployment items are used#7801
Amaury Levé (Evangelink) merged 3 commits into
mainfrom
copilot/avoid-creating-empty-deployment-folders

Conversation

CopilotAI commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

On .NET Core, MSTest was unconditionally creating empty TestResults/Deploy_*/In/MachineName/ directory trees even when no tests used [DeploymentItem].

Changes

  • TestDeployment.cs: On .NET Core, reorder the hasDeploymentItems early-return to occur beforeCreateDeploymentDirectories() is called. On .NET Framework, the original behavior is preserved (directories created before the check) for MSTest v1 compat.
  • TestDeploymentTests.cs: Update two test assertions to expect GetDeploymentDirectory() == null on .NET Core when no deployment items are present (conditionalized with #if NETFRAMEWORK).
#if NETFRAMEWORKRunDirectories=_deploymentUtility.CreateDeploymentDirectories(runContext,firstTestSource);// Directories created for MSTest v1 compat even with no deployment itemsif(!hasDeploymentItems)returnfalse;
#else
// On .NET Core, skip directory creation entirely when there's nothing to deployif(!hasDeploymentItems)returnfalse;RunDirectories=_deploymentUtility.CreateDeploymentDirectories(runContext,firstTestSource);
#endif

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet test test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj -f net9.0 --filter FullyQualifiedName~TestDeploymentTests (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj -f net9.0 -c Debug (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet test test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj -f net9.0 --filter FullyQualifiedName~TestDeploymentTests (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj -f net9.0 -c Debug (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

CopilotAI requested review from Copilot and removed request for CopilotApril 24, 2026 08:40
CopilotAI changed the title [WIP] Fix issue of creating empty deployment item foldersAvoid creating empty deployment directories on .NET Core when no deployment items are usedApr 24, 2026
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review April 24, 2026 08:47
CopilotAI review requested due to automatic review settings April 24, 2026 08:47

CopilotAI 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.

Pull request overview

Updates MSTest adapter deployment behavior to avoid creating empty TestResults/Deploy_*/... directory trees on .NET (Core/NETCOREAPP) when no tests use [DeploymentItem], while preserving MSTest v1 compatibility behavior on .NET Framework.

Changes:

  • Reorders the hasDeploymentItems early-return on non-NETFRAMEWORK builds to skip CreateDeploymentDirectories() entirely when there’s nothing to deploy.
  • Preserves .NET Framework behavior by still creating deployment directories even when no deployment items exist.
  • Updates unit tests to assert GetDeploymentDirectory() == null on non-NETFRAMEWORK in “no deployment items” cases.
Show a summary per file
FileDescription
src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.csAvoids directory creation on non-NETFRAMEWORK when no deployment items are present; keeps NETFRAMEWORK compat behavior.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.csAdjusts assertions to match the new NETFRAMEWORK vs non-NETFRAMEWORK behavior.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment threadsrc/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs Outdated
auto-merge was automatically disabled April 24, 2026 10:35

Merge commits are not allowed on this repository

@Evangelink
Amaury Levé (Evangelink) merged commit a62f1b8 into mainApr 24, 2026
10 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/avoid-creating-empty-deployment-folders branch April 24, 2026 11:36
Sign up for freeto 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.

Avoid creating deployment item folders when not used

4 participants

@Evangelink@YuliiaKovalova