Skip to content

[Repo Assist] Fix: respect (IsTestProject)false(/IsTestProject) MSBuild property to exclude projects from Test Explorer#2139

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-istestproject-msbuild-property-1970-88609a4c031c18a4
Draft

[Repo Assist] Fix: respect (IsTestProject)false(/IsTestProject) MSBuild property to exclude projects from Test Explorer#2139
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-istestproject-msbuild-property-1970-88609a4c031c18a4

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 1, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Closes #1970

Users who have projects that reference test SDK packages (via shared paket dependencies or otherwise) but explicitly set (IsTestProject)false(/IsTestProject) in their project file still see those projects in the Test Explorer and receive "no tests discovered" warnings. This PR fixes that.

Root Cause

ProjectExt.isTestProject in TestExplorer.fs determines whether a project should appear in the Test Explorer by checking if its package references include Microsoft.TestPlatform.TestHost or Microsoft.NET.Test.Sdk. This check ignores the IsTestProject MSBuild property, which is the authoritative way in .NET to declare whether a project is a test project.

The Project DTO already exposes IsTestProject: bool via project.Info.IsTestProject (populated from FsAutoComplete's ProjectResponseInfoDotnetSdk). This property correctly reflects MSBuild's computed value: it is set to true by the Microsoft.NET.Test.Sdk package targets when the SDK is present, and overridden to false when the user adds (IsTestProject)false(/IsTestProject) to their project file.

Fix

Replace the manual package-reference scan with a direct check of project.Info.IsTestProject:

// Before:
let isTestProject (project: Project) =
    let testProjectIndicators =
        set [ "Microsoft.TestPlatform.TestHost"; "Microsoft.NET.Test.Sdk" ]
    project.PackageReferences
    |> Array.exists (fun pr -> Set.contains pr.Name testProjectIndicators)

// After:
let isTestProject (project: Project) =
    project.Info.IsTestProject

This is semantically equivalent for standard projects (the Microsoft.NET.Test.Sdk package sets IsTestProject=true in its .targets file), while correctly respecting explicit user overrides.

Trade-offs

  • Standard projects (xUnit, NUnit, MSTest): No behaviour change — these all include Microsoft.NET.Test.Sdk, which sets IsTestProject=true.
  • Expecto projects: Typically include Microsoft.NET.Test.Sdk transitively (or directly), so IsTestProject=true. If an Expecto project does not use Test SDK, IsTestProject may be false and would no longer appear in Test Explorer. This is actually correct — without Test SDK, dotnet test --list-tests wouldn't work on it anyway.
  • Projects with explicit (IsTestProject)false(/IsTestProject): Now correctly excluded from Test Explorer. This is the fix for MSBuild <IsTestProject> is ignored #1970.
  • Removing the manual package list: No more need to update this list if new test runners introduce different SDK package names.

Test Status

⚠️ Infrastructure limitation: dotnet paket restore and yarn install are unavailable in this environment due to network restrictions, so a full build cannot be run.

The change is a one-line simplification from a multi-line array scan to a single property access. The IsTestProject field is of type bool and is already used elsewhere in TestExplorer.fs (e.g., project.Info.TargetFramework). The change is syntactically and type-correct.

Generated by Repo Assist

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

Generated by Repo Assist

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@da02dddebe71d9a937665abdcd1f5214dab852a7

Replace the manual package-reference check (looking for
Microsoft.TestPlatform.TestHost / Microsoft.NET.Test.Sdk) with
project.Info.IsTestProject, which is the authoritative MSBuild value
already computed by FsAutoComplete.

Fixes #1970: users who set <IsTestProject>false</IsTestProject> in their
project file to prevent a paket-shared project from appearing in Test
Explorer were ignored because the old check only looked at package
references.

The MSBuild property IsTestProject is set to true by the
Microsoft.NET.Test.Sdk targets whenever test SDK packages are present,
so the new check is semantically equivalent for standard projects while
also respecting explicit user overrides.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSBuild <IsTestProject> is ignored

0 participants