Closed Tyrrrz closed 1 year ago
It does contain some run-time dependencies in the RazorBlade
assembly, which most notably includes the base classes for templates.
Ah, I see, sorry. I was under the impression that the base classes were also generated by the source generator. Do you think that would be doable? It will probably mean that templates compiled in two different assemblies won't have the same base class though.
I suppose I could embed the code from the base classes directly into the template, but that would be a burden to maintain. Compatibility on shared stuff like HtmlString
would also have this issue.
Why would you like to avoid the runtime library?
I don't have a direct need for it right now, but it would be beneficial in case I was planning to use RazorBlade inside a library. It was one of the things I was experimenting with in MiniRazor, and for some reason I thought RazorBlade already solved that problem. No problem though, I will close the issue :)
Well, actually I think I could solve that by adding a MSBuild property such as <RazorBladeEmbedded>true</RazorBladeEmbedded>
which would then embed an internal
version of the runtime library and remove the dependency.
As everything would be internal
, you shouldn't have issues with inter-assembly dependencies.
I'll reopen this, I might want to play with this idea as well 🙂
Oops, I closed the wrong issue
This is now released in v0.4.0 🙂
The self-contained mode will be enabled by default with:
<ItemGroup>
<PackageReference Include="RazorBlade" Version="0.4.0" ExcludeAssets="compile;runtime" PrivateAssets="all" />
</ItemGroup>
But you can also control this behavior manually with:
<PropertyGroup>
<RazorBladeEmbeddedLibrary>true</RazorBladeEmbeddedLibrary>
</PropertyGroup>
Awesome!
If I understand correctly, RazorBlade doesn't have any run-time dependencies, which means it should be marked as a development dependency. Installing it will automatically add
PrivateAssets="all"
to the package reference.To do it, you need to add this property to the project file: