Skip to content

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

Merged
Evangelink merged 3 commits intomainfrom
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
Evangelink merged 3 commits intomainfrom
copilot/avoid-creating-empty-deployment-folders

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

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 before CreateDeploymentDirectories() 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 NETFRAMEWORK
RunDirectories = _deploymentUtility.CreateDeploymentDirectories(runContext, firstTestSource);
// Directories created for MSTest v1 compat even with no deployment items
if (!hasDeploymentItems)
    return false;
#else
// On .NET Core, skip directory creation entirely when there's nothing to deploy
if (!hasDeploymentItems)
    return false;
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:

Copilot AI requested review from Copilot and removed request for Copilot April 24, 2026 08:29
Copilot AI linked an issue Apr 24, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot April 24, 2026 08:40
Copilot AI changed the title [WIP] Fix issue of creating empty deployment item folders Avoid creating empty deployment directories on .NET Core when no deployment items are used Apr 24, 2026
Copilot AI requested a review from Evangelink April 24, 2026 08:41
@Evangelink Evangelink marked this pull request as ready for review April 24, 2026 08:47
Copilot AI review requested due to automatic review settings April 24, 2026 08:47
@Evangelink Evangelink enabled auto-merge April 24, 2026 08:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
File Description
src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs Avoids directory creation on non-NETFRAMEWORK when no deployment items are present; keeps NETFRAMEWORK compat behavior.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs Adjusts assertions to match the new NETFRAMEWORK vs non-NETFRAMEWORK behavior.

Copilot's findings

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

Comment thread src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs Outdated
Copilot AI requested a review from Evangelink April 24, 2026 09:53
auto-merge was automatically disabled April 24, 2026 10:35

Merge commits are not allowed on this repository

@Evangelink Evangelink merged commit a62f1b8 into main Apr 24, 2026
10 checks passed
@Evangelink Evangelink deleted the copilot/avoid-creating-empty-deployment-folders branch April 24, 2026 11:36
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.

Avoid creating deployment item folders when not used

4 participants