C# 使用ms build预编译asp.net视图
当我通过visual studio部署asp.net应用程序时,我知道我只需在发布期间选中C# 使用ms build预编译asp.net视图,c#,asp.net,asp.net-mvc,visual-studio,msbuild,C#,Asp.net,Asp.net Mvc,Visual Studio,Msbuild,当我通过visual studio部署asp.net应用程序时,我知道我只需在发布期间选中预编译,然后取消选中允许预编译站点可更新 我想用msbuild工具做同样的事情,我正在使用/p:MvcBuildViews=true/p:EnableUpdateable=false但是当我转到IIS并打开视图时,它们仍然有自己的内容,这意味着它们没有预编译,对吗 他们应该有一行这是一个由预编译工具生成的标记文件,就像他们从VS发布时所做的那样。我是否遗漏了什么 使用ms build预编译asp.net视图
预编译
,然后取消选中允许预编译站点可更新
我想用msbuild
工具做同样的事情,我正在使用/p:MvcBuildViews=true/p:EnableUpdateable=false
但是当我转到IIS
并打开视图时,它们仍然有自己的内容,这意味着它们没有预编译,对吗
他们应该有一行这是一个由预编译工具生成的标记文件,就像他们从VS发布时所做的那样。我是否遗漏了什么
使用ms build预编译asp.net视图
您应该使用参数/p:precompilebeforeprealish=true
,而不是/p:mvcbuildview=true
MvcBuildViews
经常被错误地认为是激活后会导致预编译视图的内容。事实上只需将视图包含到构建过程中,但不会将这些视图编译到project binaries文件夹中
当我们在文件发布选项中选中复选框precompileduringpublish
并取消选中复选框Allow precompiled site to updateable
,我们将在FolderProfile.pubxml
文件中获得以下属性设置:
<PropertyGroup>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
</PropertyGroup>
msbuild.exe "TestPrecompiled.csproj" /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:PrecompileBeforePublish=true;EnableUpdateable=false
当然,您可以同时使用参数和.pubxml
文件,命令行中的参数将覆盖.pubxml
文件中的属性:
<PropertyGroup>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
</PropertyGroup>
msbuild.exe "TestPrecompiled.csproj" /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:PrecompileBeforePublish=true;EnableUpdateable=false
发布完成后,打开发布文件夹中的.cshtml文件,我们将得到一行这是由预编译工具生成的标记文件,不应删除代码>从VS发布时的操作:
有关更多详细信息,请参阅。非常感谢,这非常有用:)