Based on the YAML in the comments, this looks like a paths on disk issue, from the task help reference.
- The PublishBuildArtifacts task has a default path of
$(Build.ArtifactStagingDirectory)
; you have overridden this to $(Build.ArtifactStagingDirectory)\Packages
. If this is set correctly when you look at artefacts for the build you should be able to download your test assemblies and their dependencies which were uploaded from this location.
- The DownloadBuildArtifacts task has a default
downloadPath
of $(System.ArtifactsDirectory)
which the YAML view indicates you haven't overridden.
- The VSTest task has a default
searchPath
of $(System.DefaultWorkingDirectory)
; the YAML view indicates you have set this to $(Agent.BuildDirectory)\Bin
.
The exact behaviour here may depend on how your agents have been set up for their disk paths. $(Agent.BuildDirectory)
will usually be one of the numbered subdirectories from the agent's base working path. Interestingly, while DownloadBuildArtifacts
' documentation says $(System.ArtifactsDirectory)
is its default, this does not appear in the current predefined variables list; if it in fact refers to $(Build.ArtifactStagingDirectory)
, this defaults to the "numbered_build_subdirectory\a".
As your test search path will expand to "numbered_build_subdirectory\Bin", I expect that (assuming the files are being correctly published) they are being downloaded to a location that sits outside the search path the test task is targeting, which would explain why no tests are being found.
I would suggest modifying the download and search paths for DownloadBuildArtifacts
and VSTest
to be the same and relative to the base directory, eg: $(Agent.BuildDirectory)\Tests
(or whatever is appropriate for your pipeline).