Apologies if this is not the correct use of this forum but I am really struggling…
I have a Playwright project set up using C# and I’m trying to get Extent Reports working. (I realise C# is not the best choice for Playwright but this is out of my control just now).
When I run the test I get this error, complaining about the TearDown FlushReport function:
TearDown : System.TypeLoadException : Could not load type 'Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine' from assembly 'Microsoft.AspNetCore.Razor.Language, Version=6.0.33.0
I understand it may be caused by incompatible package versions but I am new to coding and don’t know how I know what is or isn’t compatible? Has anyone come across this issue before, or able to offer any guidance?
These are my nuget package versions:
<PackageReference Include="ExtentReports" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.33" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.46.0" />
<PackageReference Include="Microsoft.Playwright.TestAdapter" Version="1.46.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
And my code:
public static void InitialiseReport()
{
string dir = AppDomain.CurrentDomain.BaseDirectory;
string testReportPath = dir.Replace("bin\\Debug\\net8.0", "TestResults " + DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss"));
string reportName = "Test Report" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(testReportPath);
htmlReporter.Config.DocumentTitle = reportName;
_extentReports = new ExtentReports();
_extentReports.AttachReporter(htmlReporter);
}
public static void FlushReport()
{
_extentReports.Flush();
}
Thanks very much and apologies again if this is not correct use of this forum.