toddams / RazorLight

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

Example that works in LinqPad #339

Closed Vaccano closed 4 years ago

Vaccano commented 4 years ago

Is your feature request related to a problem? Please describe. When I tried to create the basic example using LinqPad I got the following error:

Can't load metadata reference from the entry assembly. Make sure PreserveCompilationContext is set to true in *.csproj file

Describe the solution you'd like I would be nice if there was an easy to to get an example to run in LinqPad. That way it is would be easy to test with.

Additional context Here is the code I used to try to get this to run in LinqPad:

async void Main()
{
    var engine = new RazorLightEngineBuilder()
        .UseFileSystemProject("C:\\path\\to\\view\\Pages")
        .UseMemoryCachingProvider()
        .Build();

    string template = "Hello, @Model.Name. Welcome to RazorLight repository";
    ViewModel model = new ViewModel { Name = "John Doe" };

    string result = await engine.CompileRenderStringAsync("templateKey", template, model);
}

public class ViewModel
{
    public string Name {get; set;}
}
Vaccano commented 4 years ago

Nevermind. The issue is with a setting in the project file. I don't know if that would even be possible in LinpPad.

jzabroski commented 4 years ago

Please ask Linqpad for help

On Wed, May 6, 2020, 6:40 PM Vaccano notifications@github.com wrote:

Nevermind. The issue is with a setting in the project file. I don't know if that would even be possible in LinpPad.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/toddams/RazorLight/issues/339#issuecomment-624928039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADNH7MW6CFDS3RXOKZXDILRQHRNRANCNFSM4M22PV4A .