解决方案范围的脚手架配置存储在scaffolding.config
与解决方案文件位于同一文件夹中的位置。
在安装阶段MvcScaffolding
包启动init.ps
脚本(您可以在<packages folder>\MvcScaffolding.<version>\tools
目录中找到它)。脚本计数aspx
和视图cshtml
以及vbhtml
基于这些数字决定将使用哪个视图脚手架。这是这个逻辑的一部分:
function InferPreferredViewEngine() {
# Assume you want Razor except if you already have some ASPX views and no Razor ones
if ((CountSolutionFilesByExtension aspx) -eq 0) { return "razor" }
if (((CountSolutionFilesByExtension cshtml) -gt 0) -or ((CountSolutionFilesByExtension vbhtml) -gt 0)) { return "razor" }
return "aspx"
}
# Infer which view engine you're using based on the files in your project
$viewScaffolder = if ([string](InferPreferredViewEngine) -eq 'aspx') { "MvcScaffolding.AspxView" } else { "MvcScaffolding.RazorView" }
Set-DefaultScaffolder -Name View -Scaffolder $viewScaffolder -SolutionWide -DoNotOverwriteExistingSetting
因此,您可以使用以下命令切换视图脚手架:
Set-DefaultScaffolder -Name View -Scaffolder "MvcScaffolding.RazorView" -SolutionWide
Set-DefaultScaffolder -Name View -Scaffolder "MvcScaffolding.AspxView" -SolutionWide
或者您可以手动编辑scaffolding.config
文件并替换ScaffolderName
标签中属性的值:
<Default DefaultName="View" ScaffolderName="put here either MvcScaffolding.RazorView or MvcScaffolding.AspxView" />