TFS 2012 Visual Studio plug-in instantly creates a

2019-07-08 02:35发布

问题:

I have a problem with Visual Studio 2012 which is driving me crazy. We're developing an ASP.NET web app and on app start up it has to load a lot of stuff into memory. It sometimes takes between 20-30 for it to start up and be ready to server the first http requests.

We're using TFS source control and basically, every times someone edits a file, TFS marks the file as "checked out" (the little red check mark appears next to the filename icon in the Solution Explorer) AND instantly creates and deletes a "app_offline.htm" file in the root of the web app.

This causes the Web Application to unload. I used logging in the Application_Start and Application_End events to find this out. Then I used SysInternals Process Monitor to see what activity was happening. When I saw app_offline.htm being mentioned within the cryptic output of procmon, I used a separate File System Watcher called Directory Monitor which confirmed that the app_offline.htm was indeed being created and instantly deleted.

The knock-on effect of this is that if you have a few changes to make, the app has to unload/reload many many times during development. This is wasting hours.

Not only that, the constantly reloading of the app domain causes IIS to eventually run out of memory and then we have to do an IISRESET.

Does anyone know why TFS creates this file? And whether there is any way to get it to stop?

回答1:

I have discovered a work-around.

1) Go to the location in which Visual Studio caches the app_offline.htm file C:\Users[user]\AppData\Roaming\Microsoft\VisualStudio\11.0\ (replace [user] with your username)

2) Delete the app_offline.htm file

(NOTE: this alone will not solve it, as VS regenerates the file again when it's not found)

3) Create a directory called app_offline.htm (a DIRECTORY!)

This essentially causes an error with the process that attempts to use the file because it's not a file and the name clash means VS cannot try to recreate the file. Luckily the error has no unwanted side-effects.

Now continue with using VS and Team Foundation Server and enjoy not constantly having the appdomain reloaded!



回答2:

If you will publish from Visual Studio to directory under IIS , then it will happen. And VS 2012 holds that file under the location

C:\Users\[user]\AppData\Roaming\Microsoft\VisualStudio\11.0\app_offline.htm

The easy soultion may be to bever publish directly to your server. And I believe you shouldn't, you can publish to a local folder then copy the site up to desired location.

Once you remove the mapping ( publishing directly to server ) then I am sure when you "checked out" a file it will not instantly creates and deletes a "app_offline.htm" file in the root of the web app. Hope it helps.