简体   繁体   中英

PrecompileBeforePublish using Msbuild

We are using Windows Azure to host our application on a Cloud Service and use Powershell to build and package the website using msbuild .

On releasing our first response time is very slow so naturally we'd need to precompile the application.

There's plenty of documentation for Precompiling using the aspnet_compiler , however I cannot find any official documentation on using:

msbuild Web.sln /p:PrecompileBeforePublish=true

A Google search targeted at MSDN gives me nothing whilst usually MSDN is fairly thorough. All I can see is a useful Stack post from earlier this year.

So does anyone know of any formal documentation for PrecompileBeforePublish ? Am I looking at the wrong source?

Failing that, what exactly does the flag provide us, is it the same as Precompilation for Deployment with an Updatable UI ( reference )?

I think, your problem is not pre-compilation and I see, you have done precompiling well.

I think your project is too big (Check your final bin directory size) IIS read every dll, and debug symbols and load them in to memory before running any line of code.

If your project size too big, and your virtual environment resorces are low, magnetic disk, low ram, low cpu, so there is no magic in it.

Recommendations:

  1. Try to reduce size of the project output. (Removing debug symbols can be an option).
  2. Remove all not used references... (Both .net and 3rd Party) (edit, added)
  3. Scale up your environment configuration.

Regards...

It's been a while since this question was posted and there is still no good answer. Recently I wanted to change the way MSBuild runs aspnet_compiler.exe but found no documentation. I did a bit of digging around and here is my experience.

Precompiling will only happen if you use both the DeployOnBuild and PrecompileBeforePublish parameters. Other usable parameters are EnableUpdateable and UseFixedNames .

msbuild Web.sln /p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:EnableUpdateable=false /p:UseFixedNames=true

You can achieve a similar result if you change precompile options in Visual Studio. This can be done at Project > Publish > Configure > Settings > File Publish Options > Precompile during publishing > Configure .

link to image

This is how the parameters should appear in your .pubxml file:

    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>False</EnableUpdateable>
    <DebugSymbols>True</DebugSymbols>
    <WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
    <UseFixedNames>True</UseFixedNames>

Since there is no documentation to be found you might want to change these options and see the resulting .pubxml file to see what further parameters to use in the command line.

rex the solution to your problem is, add a new web deployment project for your website which will automatically pre-compile your website and the project will contain pre-compiled web outputs. If you don't get the web deployment project in your right click please download the tool for Visual Studio with respect to either 32 or 64 bit which will be added to your visual studio Or if you want to do it through MS Build you need to refer to https://msdn.microsoft.com/en-us/library/ms227972.aspx or you can also refer to http://www.asp.net/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/precompiling-your-website-vb I hope I helped you in some way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM