3

I have an ASP.NET 4.6.1 application that I am trying to deploy to a remote web server using TeamCity and MSBuild. Below is the MSBuild build step within TeamCity.

enter image description here

When I run the build in TeamCity, it always fails on this build step with a FILE_IN_USE_ERROR. The DLLs that are being updated before the error are usually the same, but sometimes they are different.

[MSBuild output] Info: Updating file (MyApp\bin\roslyn\Microsoft.VisualBasic.Core.targets). [10:35:23]

[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.AppContext.dll). [10:35:23]

[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.Collections.Immutable.dll). [10:35:23]

[MSBuild output] MSDEPLOY : error Code: ERROR_FILE_IN_USE [C:\BuildAgent\work\b89cd3dfa447b\MyApp\MyApp.csproj]

I've already read through many articles (here, here, here, and here) suggesting that I drop an app_offline.htm file before deploying so that the IIS can re-route traffic and the file locking issues will stop. I tried that and it doesn't work. I still get the file in use issues during this build step.

I've also read in plenty of other discussions that another solution is to stop the application pool, deploy the app updates, and start the application pool. This is not a realistic solution because the deployment usually lasts between 15 and 20 minutes. Plus, this doesn't allow me to show a nice message to any current users.

I've been reading about this for a while now and it seems like this is a common use case for deployment to an IIS web server. Shouldn't this just work without locking files? Does anybody know of any other solutions to this problem?

Ryan V
  • 480
  • 3
  • 13
  • Interesting... I have just started to get this same issue. I am running an MSBuild.exe with similar parameters. I have just updated to the latest version of teamcity also – Gwasshoppa May 21 '18 at 04:22
  • I am getting this same problem :( It's extra weird given the .csproj file is not being deployed, nor is it in use, or even on the server. This must be a bug. But it is ruining publishing! I'm just doing a web deploy on an IIS server with asp core – NightCabbage Nov 23 '18 at 01:46

1 Answers1

1

I would try by stopping app pool to see if that`s a root cause of the issue.

But I'm not sure why it fails on .csproj file, because usually you don`t deploy those on server. So either it fails on different file (that is actually in use by web application) or it fails during build, not deploy (than app-pool stop will have no affect).

Victor Fialkin
  • 165
  • 4
  • 7