Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 808
Luke Merrett Avatar asked Nov 05 '13 10:11

Luke Merrett


People also ask

How use MSBuild command line?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.


2 Answers

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.

like image 120
Zolibatan Avatar answered Sep 22 '22 21:09

Zolibatan


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...

like image 32
efaruk Avatar answered Sep 23 '22 21:09

efaruk