Deployment of PrecompiledApp issue
Asked Answered
H

1

9

The autogenerated PrecompiledApp.config is causing me some headache. Im automating the deployment of an older web site and 50% of the time when I deploy I get this error:

System.IO.IOException: The process cannot access the file '\\web.prod.local\c$\Sites\Website\PrecompiledApp.config' because it is being used by another process.

Content:

<precompiledApp version="2" updatable="true"/>

To the best of my knowledge websites uses some shadow copy feature to allow updating the site "runtime", with things such as app.config etc. However this 1 file seems to be an exception.

Can anyone suggest a workaround besides stopping the website while deploying?

Kind regards

Horseflesh answered 16/10, 2013 at 8:2 Comment(9)
Yes but in a VERY primitive way unfortunatly. I simply check the content of the file for changes. If no changes, I do not attempt to overwrite. In the long run i'm looking into removing the file completely. This primitive fix resolves all our currently deploy errors, so though it ugly, it effictive.Horseflesh
May i ask how you accomplish this?Dissimilation
Read the content of the deployed PrecompiledApp, check against the content of the PrecompiledApp which you are about to deploy. If it differs at all overwrite. In our case we cannot depend timestamps of the file due to some old decisions made with our automated deployment. But please note that this is ONLY a temporary solution as im doing a complete overhaul of the deployment pipeline and currently just have to maintain the old one. I would not recommend doing it this way. Use timestamps instead with ex robocopy of better yet do a complete remove/install every time, as im doing now.Horseflesh
My TeamCity deployment sometimes give this eror, any clue how to solve it once and for all?Prato
@RosdiKasim: You can use robocopy and use its retry and wait feature, that should handle it. But you should proberbly use a dedicated tool for deployment instead, like say Octopus Deploy, or the one from Thoughworks (which is a branch of Octopus i think) or something else. TeamCity is build server, not a swiss army knife for doing X number of very complex tasks, IMHO :). Build is one domain, use TC if you like, Deploy is a completely different domain use something else.Horseflesh
So if the file is different in any way, you overwrite it, but how about if the destination file is in use? You can't overwrite it then can you?Samathasamau
This seems to me like asynchronous deployment. Meaning the PrecompiledApp.config is being generated due to a deployment, and then another deployment occurs asynchronously and while the former deployment is still using the file, the new deployment can't write to it.Samathasamau
My deployment script stops the website in IIS and this file still causes my builds to intermittently fail.Selfregard
I have to restart or stop the app pool. Did anyone find an actual solution. I am planning to write script to stop appPool before deploy and start back. I am using TFS 2013 to build/autodeploy.Maximamaximal
R
1

Judging by the path in the error message I see you're trying to copy the files over a network share while deploying. This is bad practice to update the files directly over a network share or FTP etc. And this is the reason, actually. Network deployment is slow and while some files are still being updated/uploaded - the ASP.NET on the server is already trying to recycle the app, copy the files to "Temporary ASP.NET folders" etc. etc. etc.

Deployment best practice:

ZIP your precompiled site, upload, then run UNZIP on the server remotely

Here's how you run UNZIP remotely:

plink -ssh -l USERNAME -pw PASSWORD web.prod.local c:\Sites\Website\unzip -q -o c:\Sites\Website\site.zip -d c:\Sites\Website\

"plink" is a free SSH tool for windows (command-line) you need it on your dev machine

"web.prod.local" is your server address.

"c:\Sites\Website\" is the path your website on the server

You need SSH installed on your server to run commands remotely, the simplest option is too install the free tool: "freesshd" (google it)

Drop "unzip.exe" on the server as well, you see it's being called right there. Simplest way is to drop it right into the c:\Sites\Website\

PS. This is just an example, you can come up with your own solution

Rive answered 1/5, 2015 at 11:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.