Hi all.
We use Razorlight (via FluentEmail) to generate emails (strings) from cshtml files (razor templates).
After upgrading from .netcore 2.2 to 3.1 the code works and tests work through `dotnet test`, but fail when run under ncrunch.
I've made a small reproduction here:
https://github.com/danzel/ncrunch-razorlight
You can run it, navigate to https://localhost:5001/weatherforecast and you'll end up at some plain text html with "Heading: ExpectedString".
You can also run `dotnet test` in the solution folder and the test will pass.
But when run under ncrunch you end up with
Quote:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
RazorLight.Compilation.TemplateCompilationException: Failed to compile generated Razor template:
- (3:35) The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
- (3:63) Predefined type 'System.String' is not defined or imported
.... lots more ....
Razorlight needs these new options set in the csproj, maybe ncrunch isn't respecting them?
Code:
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<PreserveCompilationContext>true</PreserveCompilationContext>
Thanks,
Dave.