PrecompileBeforePublish使用Msbuild

Luk*_*ett 13 c# asp.net msbuild

我们正在使用Windows Azure托管我们的应用程序Cloud Service并使用它Powershell来构建和打包网站msbuild.

在发布时,我们的第一个响应时间非常慢,因此我们需要预编译应用程序.

有很多关于使用aspnet_compiler进行预编译的文档,但是我找不到任何关于使用的官方文档:

msbuild Web.sln /p:PrecompileBeforePublish=true
Run Code Online (Sandbox Code Playgroud)

一个谷歌搜索定位于MSDN给我什么,而通常MSDN是相当彻底.我所能看到的是今年早些时候的一个有用的Stack帖子.

那么有谁知道任何正式文件PrecompileBeforePublish?我看错了消息来源吗?

如果不这样,旗帜究竟为我们提供了什么,它与Precompilation for Deployment with an Updatable UI(参考)是一样的吗?

小智 5

这个问题发布已经有一段时间了,仍然没有好的答案。最近我想改变 MSBuild 运行 aspnet_compiler.exe 的方式,但没有找到文档。我做了一些挖掘,这是我的经验。

只有在同时使用DeployOnBuildPrecompileBeforePublish参数时才会进行预编译。其他可用参数是EnableUpdateableUseFixedNames

msbuild Web.sln /p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:EnableUpdateable=false /p:UseFixedNames=true
Run Code Online (Sandbox Code Playgroud)

如果在 Visual Studio 中更改预编译选项,则可以获得类似的结果。这可以在Project > Publish > Configure > Settings > File Publish Options > Precompile during publishing > Configure.

图片链接

这是参数在您的 .pubxml 文件中的显示方式:

    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>False</EnableUpdateable>
    <DebugSymbols>True</DebugSymbols>
    <WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
    <UseFixedNames>True</UseFixedNames>
Run Code Online (Sandbox Code Playgroud)

由于找不到文档,您可能希望更改这些选项并查看生成的 .pubxml 文件,以了解在命令行中使用的其他参数。


小智 -1

rex 问题的解决方案是,为您的网站添加一个新的 Web 部署项目,该项目将自动预编译您的网站,并且该项目将包含预编译的 Web 输出。如果您没有在右键单击中获得 Web 部署项目,请下载适用于 32 位或 64 位的 Visual Studio 工具,该工具将添加到您的 Visual Studio 中或者如果您想通过 MS Build 来完成此操作,则需要请参阅https://msdn.microsoft.com/en-us/library/ms227972.aspx或者您也可以参考http://www.asp.net/web-forms/overview/older-versions-getting-started /deploying-web-site-projects/precompiling-your-website-vb 我希望我能以某种方式帮助你。