microsoft / microsoft/MSBuildSdks

Microsoft.Build.RunVSTest fails on multi-targeting test projects

Open
#564 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
508
Forks
94
Avg merge
6h 40m
Merged PRs (30d)
2

Description

When a test project defines the TargetFrameworks msbuild property instead of the singular TargetFramework property, msbuild /t:test fails when invoking the RunVSTestTask task because all its inputs are empty.

MSBuild version 17.12.0-preview-24412-02+0716e1c2a for .NET Framework


Static graph loaded in 1.145 seconds: 19 nodes, 102 edges
Loading the following project cache plugin: MSBuildCacheLocalPlugin
Microsoft.VisualStudio.Threading.Analyzers -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.VisualBasic -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.CSharp -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.CodeFixes -> Cache Hit
Microsoft.VisualStudio.Threading -> Cache Hit
Microsoft.VisualStudio.Threading -> Cache Hit
Microsoft.VisualStudio.Threading -> Cache Hit
Microsoft.VisualStudio.Threading -> Cache Hit
Microsoft.VisualStudio.Threading -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.Tests -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.Tests -> Cache Hit
Microsoft.VisualStudio.Threading.Analyzers.Tests -> Cache Hit
C:\.tools\.nuget\packages\microsoft.build.runvstest\1.0.319\build\Microsoft.Build.RunVSTest.targets(19,5): error : Test file path cannot be empty or null. [C:\Users\andarno\source\repos\vs-threading\test\Microsoft.VisualStudio.Threading.Analyzers.Tests\Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj]
  VSTest version 17.12.0-preview-24373-01 (x64)

RUNVSTESTTASK : error : No arguments were specified. [C:\Users\andarno\source\repos\vs-threading\test\Microsoft.VisualStudio.Threading.Analyzers.Tests\Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj]
  Usage: vstest.console.exe [Arguments] [Options] [[--] <RunSettings arguments>...]]

The error goes on to include the full USAGE doc for vstest.console.

Workaround

Specify /p:TargetFramework=net6.0 at the command line and get just one TF tested.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with msbuild /t:test on a project using TargetFrameworks, then inspect Microsoft.Build.RunVSTest.targets at line 19 and the RunVSTestTask inputs. Use the reported command-line workaround as a comparison; done means multi-targeting test projects invoke VSTest without empty paths or arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.