DOTNET 6 Error - Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:95
Top Results From Across the Web
Cannot find compilation library location for package ...
Just upgraded a web project to .NET 6.0. Project compiles but when I run the site I get the following error: InvalidOperationException: Cannot...
Read more >Cannot find compilation library location for package ' ...
Upgrading from 5.0 to 6.0 yields InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs #38892.
Read more >Cannot find compilation library location for package ...
Within my launchsettings.json file I created profile for IIS (Not IISExpress). ... When I install "System.Security.Cryptography.Pkcs" via nuget ...
Read more >Cannot find compilation library 'System.Security. ...
Luckily I found a better fix: I just had to install the System.Security.Cryptography.Pkcs NuGet package, which immediately solved the issue.
Read more >Cannot find compilation library location for package ...
Works fine using IIS Express but when I try to run in IIS I get the Error ... compilation library location for package...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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