The original contents of app_offline.htm
are indeed stored in a mystery location (probably hard-coded inside of one of the binaries), however Visual Studio does write the contents to a physical file before uploading it.
If you've published at least once, a simple search in a command prompt using dir C:\app_offline.htm /s/a/b
should come up with the location where the temporary file is written. It should be something like C:\Users\username\AppData\Roaming\Microsoft\VisualStudio\16.0_5fc0d832\app_offline.htm
. I'm not sure if that hexidecimal string at the end is the same for every installation or user.
Setting that file to read-only does indeed prevent Visual Studio from overwriting its content, and modifications to that file will in fact be uploaded during publishing. However, it causes an internal error that can eventually prevent it from uploading over time.
The app_offline.htm
is written before the post-build event, so it just needs to be overwritten before Visual Studio starts uploading.
A more resilient approach is to do the following:
1) Create a custom app_offline.htm
in your project. (Not in the root folder of your project, it will prevent you from using F5 Start Debugging.)
2) Use the post-build event to copy the custom app_offline.htm
from your project folder to Visual Studio's staging folder.
Post-build event command line:
copy /y "$(ProjectDir)Resources\app_offline.htm"
"C:\Users\%username%\AppData\Roaming\Microsoft\VisualStudio\16.0_5fc0d832\app_offline.htm"