使用RazorGenerator.MsBuild自定义razor页
创建控制台项目


使用类库项目,.net standard.2.0
nuget安装RazorGenerator.MsBuild
这样在项目的packages目录能看到RazorGenerator.MsBuild.2.5.0
razor页类定义
namespace RazorLib
{
public abstract class RazorPage
{
public virtual void Execute()
{
}
public virtual void WriteLiteral(string str)
{
}
}
}
index.cshtml
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@
@inherits RazorLib.RazorPage
开头的注释行是必须的,具体含义到RazorGenerator.MsBuild的github查看
添加Razor.build到项目
需要将RootNamespace改为你自己的
编辑项目文件RazorConsole.csproj
追加以下内容:
注意要用
netstandard2.0; 不要写成netstandard2.0

浙公网安备 33010602011771号