Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot profile test in Visual Studio 2019

I have a test that is taking a very long time to run when it is run alone.

I tried to profile it by right-clicking on it and selecting "Profile". When I do that, it runs the test, opens a new window with a .vsp extension, then it shows an error window with the following message:

File contains no data buffers

Googling around for this, I find several posts but they are quite out of date. (One 3 years ago says .Net Core does not support profiling).

What can I do to be able to profile my Unit Test?

Note: My test project is netcoreapp3.1 and it is testing a netstandard2.0 project. I am running using NUnit 3.12.0 and NUnit3TestAdapter 3.15.1.

like image 975
Vaccano Avatar asked Mar 05 '26 14:03

Vaccano


1 Answers

The output of the test console gives a hint:

** IMPORTANT ** Profiling .NET Core tests requires full PDB's. Be sure to set Debug information level to Full on each project to be profiled.

You need to put something like

<PropertyGroup>
  <DebugType>full</DebugType>
  <DebugSymbols>true</DebugSymbols>    
</PropertyGroup>

in any relevant project file or in the Directory.Build.props file.

Also make sure that you have an up-to-date test SDK. I also needed to set the "Processor Architecture for AnyCPU projects" to "Auto".

like image 54
MarkusParker Avatar answered Mar 08 '26 12:03

MarkusParker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!