RazorLight: DOTNET 6 Error - Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
Describe the bug Existing tests fail after upgrade.
To Reproduce Upgrade Test Project from Dotnet 5 to Dotnet 6:
Expected behavior The template should transform
Information (please complete the following information):
- OS: Windows 11
- Dotnet6
- RazorLight version: – https://www.nuget.org/packages/RazorLight/2.0.0-rc.3 – https://www.nuget.org/packages/RazorLight.NetCore3/
- Are you using the OFFICIAL RazorLight package? https://www.nuget.org/packages/razorlight
- Visual Studio version : Visual Studio Community 2022 Professional Released
Additional context TEST
public void Convert_GivenValidInput_ShouldConvert()
{
// arrange
Setup();
var data = new { Name = "TheName" };
var template = "Name is @Model.Name";
// action
var result = _engine.Convert(data, template, true);
// assert
result .Should().Be("Name is TheName");
}
IMPLEMETATION:
var result = engine.CompileRenderStringAsync(GetTemplateCachedId(templateData), templateData, data, (ExpandoObject)null).Result;
ERROR:
IIAB.Core.Common.Exceptions.RazorParsingException : One or more errors occurred. (Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs')
at IIAB.Razor.RazorTemplateEngine.Convert(Object data, String templateData, Boolean ifErrorTrySerializeAndDeserialize) in C:\Git\IIAB-netcore\src\IIAB.Razor\RazorTemplateEngine.cs:line 102
at IIAB.Razor.Tests.RazorTemplateEngineTests.Convert_GivenValidInput_ShouldConvert() in C:\Git\IIAB-netcore\src\IIAB.Razor.Tests\RazorTemplateEngineTests.cs:line 32
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 95
@leighmetzroth @jacodv We did it! https://www.nuget.org/packages/RazorLight/2.0.0-rc.6
So for people still having the issue the ultimate solution for this is setting PreserveCompilationContext to true and adding ExcludingAssembly like:
If you will try to Exclude Assembly with FullName It will not work. Additonally the RazorLightDependancyEngineBuilder is broken and all ExcludedAssemblies are ignored further in DefaultMetadataReferenceManager. @jzabroski
OK, I see the problem. I forgot I put the version in the src/Directory.Build.props not the top level build props. Should be fixed. It will be published as rc.6 unfortunately
Looks like you’ve been fighting with failures 😔 and the latest failure is because it couldn’t find the project.
I’ve never really dealt with github actions before, but looking at the code here for
alirezanet/publish-nuget, I can see that it just referencesthis.projectFile = process.env.INPUT_PROJECT_FILE_PATHwhereas the others reference both the environment variable with and without theINPUT_part. I also spotted this issue where there was a bug where theINPUT_was being ignored.Perhaps we need to switch
PROJECT_FILE_PATH: src\RazorLight\RazorLight.csprojforINPUT_PROJECT_FILE_PATH: src\RazorLight\RazorLight.csprojtemporarily?@jzabroski Thanks for the quick reply.
I have raised a PR based on the changes from the latest code by @jacodv in https://github.com/jacodv/RazorLightDotNet6/tree/branch_jdevil-Dotnet6-WebApi6
I have excluded some of the extraneous code though.
@jzabroski
Short Answer: I have successfully upgraded to .Net 6 including the latest language version
https://github.com/jacodv/RazorLightDotNet6/tree/branch_jdevil-Dotnet6-Upgrade-RazorLight-Tests Show the code and tests
Running commentary
Please have a look at this readme
https://github.com/jacodv/RazorLightDotNet6/blob/branch_jdevil-Dotnet6-Upgrade-RazorLight-Tests/DotNet6Status/README.md
I have detailed every step to reproduce as well as what must be changed to enable .Net 6
@jzabroski : My Error has todo with a dependency (System.Security.Cryptography.Pkcs) of referenced Nuget packages. It would seem that different Nuget packages depend of different versions of this dependency. I realized it by looking at the project.assets.json file in the obj folder.
I still get the error after making the above changes and referencing the new RazorLight project. If I remove the project that has all the nuget packages it works.
Three questions: