microsoft / vstest

Visual Studio Test Platform is the runner and engine that powers test explorer and vstest.console.
MIT License
889 stars 320 forks source link

dotnet test assumes different output path than dotnet build #5264

Open DWIAltonaAnalytics opened 4 weeks ago

DWIAltonaAnalytics commented 4 weeks ago

Description

in a two step build using

step 1 build:

dotnet build [SolutionPath] --configuration Release --no-restore --verbosity minimal  /property:WarningLevel=0

step 2 test:

dotnet.exe test [ProjectPath] --configuration Release --no-build --no-restore --results-directory [...]\TestResults --settings [...]\coverlet.runsettings --verbosity normal /property:SolutionDir=[SolutionPath]

I get an error that [OutputPathBase]\Release\[ProjectAssemblyName].dll was not found.

which is correct, because it can be found at [OutputPathBase]\x86\Release\[ProjectAssemblyName].dll.

If I use this for building (which is very poorly documented):

dotnet build [SolutionPath] --configuration Release --no-restore --verbosity minimal /property:AppendPlatformToOutputPath=False /property:WarningLevel=0

the test runs without that error as the build produces the output without x86

Steps to reproduce

see above

Expected behavior

dotnet test should not assume plattform/architecture is missing from the outputpath

Actual behavior

without adjusting build, the tests expect the output to be in a different place.

Environment

$> dotnet --version
8.0.401
DWIAltonaAnalytics commented 4 weeks ago

Addendum: If I add /property:AppendPlatformToOutputPath=True to the dotnet test call, it searches with plattform AnyCPU without regard to what is configured in the csproj.

nohwnd commented 4 weeks ago

Can you please build both of the above with binary log?

/bl:dotnet-build.binlog /bl:dotnet-test.binlog

I don't think we are assuming anything about the output path in dotnet test, we get it from msbuild via TargetPath: https://github.com/microsoft/vstest/blob/main/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets#L86

If you cannot share your binlog, can you please check what the value of TargetPath is in the build that is handed over to the vstest target linked above? You can do so by producing the binary log and then viewing it via the binary logger viewer: https://msbuildlog.com/