asp.netasp.net-mvcvisual-studioweb-publishing

ASP.NET MVC 5 publish precompile problems


I have used the web publishing tool to publish my MVC 5 app in the past without precompiling in the past. As part of my effort to reduce the initial load time for each page, I have modified my publish settings as shown below to precompile the app during the publish process. All of a sudden, the incredibly reliable publishing that I was used to has become a nightmare.

I have tried restarting visual studio, cleaning the solution and rebuilding, previewing vs. not previewing the changes before publish, creating a brand new publish profile, and fiddling with the advanced precompile settings time and time again. Usually after 30 minutes or so of mucking with it I can get the .precompiled files to generate and publish successfully, however I have not been able to identify what caused it to work correctly that time. The next time I go and publish without changing any settings, it will stop working again. The issue occurs when using either VS2015 or VS2017RC.

Can anyone please help point me in the right direction here? I've sunk many hours into this already and just feel like I'm going in circles at this point.

Thanks!

EDIT I took a closer look at the build output and found the call to aspnet_compiler.exe was executed with the following parameters:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p C:\Users\steve\Source\Dashboard\master\src\Agility.Web\obj\Staging\AspnetCompileMerge\Source -d C:\Users\steve\Source\Dashboard\master\src\Agility.Web\obj\Staging\AspnetCompileMerge\TempBuildDir

When I run this command directly from the command line, no .compiled files are being generated in TempBuildDir\bin.

enter image description here


Solution

  • Please try following steps.

    1. Change solution configuration to the release mode.

    2. Make sure web.config is being published.

    3. Check the web.config file's properties and see if Build Action is set to None if yes set it to Content. and run the command again.

    4. Change DashBoard.Precomiled.dll to DashBoard.Precomiled only.

    5. Check the Treat as Library Component check box as well.

    For more detail about the options visit ASP.NET Compilation Tool (Aspnet_compiler.exe)

    Thanks