toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

Cannot find compilation library location for package (From legacy website project) #508

Open fedegarciarod opened 1 year ago

fedegarciarod commented 1 year ago

Describe the bug I'm getting the following error: "Cannot find compilation library location for package". I know that in the FAQ section there is a solution to that adding a few properties into the csproj file. The problem is that my web project doesn't have this file to configure, I have the razorlight dependency added in another project that is being called by the web one. I did add the configurations to csproj on this project.

When I try to render the template form the unit test project we have, the template gets rendered correctly. But when I do it through the service layer I have in my legacy web app, Im getting the error. The website project is net 4.8 and the project where razorlight is added is 4.8/ net standard 2.0.

Does anyone know a possible solution to my problem? Is it possible to make this scenario work?

To Reproduce Project A: website project with 4.8 with a handler that references project B. Project B: DLL project 4.8/2.0 that has razorlight and renders a simple template

Information (please complete the following information):

jzabroski commented 1 year ago

So your project structure looks like:

Project A [ASP.NET MVC Classic *Website*] TargetFramework=[net48]
|
 \ Project B [Class Library] TargetFrameworks=[net48, netstandard2.0] 
  |
  \ [Package Reference] RazorLight Version=[2.3]

Is Project A using the new Project System csproj file format? If it's not, then I am not sure the flags in the FAQ will do anything. There is a thread somewhere on GitHub where the open source community has figured out how to add various project capabilities to ASP.NET Classic net48 projects so that they can use the new project system csproj file format. For example, you need to convert the Project-level node and also add the following:

  <ItemGroup>
    <ProjectCapability Include="DotNetCoreWeb" />
    <ProjectCapability Include="SupportsSystemWeb" />
    <ProjectCapability Include="LegacyRazorEditor" />
  </ItemGroup>

But you also need to take into consideration how you deploy your website, so you are not home free just yet.

jzabroski commented 1 year ago
  • Visual Studio version: Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.2.3

BTW, current verison is 17.4.0. It seems to be way faster than the version you are on. It wont solve this problem for you, though, but it will help with running unit tests, etc. faster.