体验 ASP.NET Core 1.1 中预编译 MVC Razor 视图
生活随笔
收集整理的這篇文章主要介紹了
体验 ASP.NET Core 1.1 中预编译 MVC Razor 视图
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這是從 ASP.NET Core 1.1 官方發布博文中學到的一招,可以在 dontet publish 時將 Razor 視圖編譯為 .dll 文件。
需要在 project.json 中添加如下配置:
1)在 "dependencies" 中添加:
"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Design": "1.1.0-preview4-final"2)在"tools"中添加:
"tools": {"Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tools": "1.1.0-preview4-final" }3)在"scripts"中添加:
"scripts": {"postpublish": "dotnet razor-precompile --configuration %publish:Configuration% --framework %publish:TargetFramework% --output-path %publish:OutputPath% %publish:ProjectPath%" }然后在運行 dotnet publish 命令時就會編譯 ASP.NET Core 項目中的 Razor 視圖:
Running Razor view precompilation. Precompiled views emitted to /data/AboutUs/bin/release/netcoreapp1.1/ubuntu.14.04-x64/publish/AboutUs.PrecompiledViews.dll. Successfully compiled 18 Razor views in 12734ms.MVC Razor 視圖被編譯成了一個?AboutUs.PrecompiledViews.dll 文件,運行站點時只需要這個 dll 文件,不需要 .cshtml 視圖文件了。
原文地址:http://www.cnblogs.com/dudu/p/6074625.html
.NET社區新聞,深度好文,微信中搜索dotNET跨平臺或掃描二維碼關注
總結
以上是生活随笔為你收集整理的体验 ASP.NET Core 1.1 中预编译 MVC Razor 视图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL在EF Core下的Scaff
- 下一篇: Visual Studio Code 玩