I have a problem with missing exception info when crunching in optimized mode. The coverage markers where the exception occurs and propagates does not indicate exception (no X) and the NCrunch Trace Output is missing line numbers (and hyperlink) in the stack trace. In order to find out where the exception occurs I have to start debugging and rely on VS to catch the exception dialog. This is cumbersome ;)
This behavior is consistent for me on VS2017 v15.9.4 with NCrunch 4.2.05 and XUnit 2.4.0 when I create a .NET Core project and manually switch to target framework net471 in the csproj file. (Projects with target framework netcoreapp2.1 are working as expected. Also running the same under VS2019 is working fine, but this is not an option for me).
Switching to legazy mode solves the problem, but is a bummer.
<Project Sdk="Microsoft.NET.Sdk>
<PropertyGroup><TargetFramework>net471</TargetFramework></PropertyGroup>
<ItemGroup><PackageReference Include="xunit" Version="2.4.0"/></ItemGroup>
</Project>
public class Test
{
[Fact]
public void NoExceptionInfo() {throw new Exception("No NCrunch exception info here!")}
}
Has anyone else experienced this and/or have any clues on how to solve this?
This problem is caused by the inability of the .NET 4.7.1 runtime to interpret portable PDB files. You'll find that if you compile this test project to a console application and try to run it, you'll have the same result.
You're not seeing this in the VS runner because the VS runner seems to defer to using higher versions of .NET when running tests (on my system, it seems to be using .NET 4.8 instead of 4.7.1, even though the library is clearly targeting net471).
NCrunch legacy mode doesn't support portable PDBs, so it implicitly forces the build system to instead output a non-portable PDB, which doesn't have this problem under net471.
You have two options here:
1. Switch to using a non-portable ('full') PDB instead. This is done by adding <DebugType>full</DebugType> inside the main PropertyGroup of your project file
2. Switch to a high version of .NET. 4.7.2 should work fine with portable PDBs
Both suggestions are working perfectly. I'm not sure if switching to net472 will be an option on my project (even if I can't see why not), but full PDB should be.