toddams / RazorLight

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

I have to call build() in the exec project #401

Closed Watchwolf closed 3 years ago

Watchwolf commented 3 years ago

Describe the bug If I do not call Build() from my exec project, I can't use RazorLight. I have this error when I call build() and CompileRenderAsync() from my library:

Failed to compile generated Razor template:
- (3:29) The type or namespace name 'Razor' does not exist in the namespace 'RazorLight' (are you missing an assembly reference?)
- (20:56) The type or namespace name 'TemplatePage<>' does not exist in the namespace 'RazorLight' (are you missing an assembly reference?)
- (20:69) The type or namespace name 'AsbestosEmail' could not be found (are you missing a using directive or an assembly reference?)
- (23:66) 'GeneratedTemplate.ExecuteAsync()': no suitable method found to override
- (4:4) The name 'Layout' does not exist in the current context
- (31:12) The name 'BeginContext' does not exist in the current context
- (32:12) The name 'WriteLiteral' does not exist in the current context
- (33:12) The name 'EndContext' does not exist in the current context
- (34:12) The name 'DefineSection' does not exist in the current context

To Reproduce

Temporary Solution

Expected behavior I should be able to use build()/CompileRenderAsyn() without having to call Build() from the executable.

Information (please complete the following information):

Additional context

Thank a lot for helping me.

jzabroski commented 3 years ago

I'm not sure what the problem is. Are you familiar with Microsoft DI and what Build does? Build does indeed need to get called.

Can you upload a sample project?

jzabroski commented 3 years ago

@Watchwolf Can you upload a sample project?