microsoft / MSBuildSdks

MSBuild project SDKs
MIT License
460 stars 82 forks source link

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

Open AArnott opened 2 months ago

AArnott commented 2 months ago

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.