Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to deploy web package to IIS website. By the Self-hosted Windows agent

Tags:

azure-devops

Failed to deploy web package to IIS website

I have created one ASP.NET Core application and Azure DevOps continuous integration (CI) and continuous delivery (CD) pipeline.

I have created and configure the Self-hosted Windows agents in my local machine as a service. It is working as expected.

When I run the CI/CD pipeline for the first time it is working successfully, and the web application published to my local IIS successfully.

The issue is when I commit another update to Azure DevOps git repository it is failed to deploy web package to my local IIS website with the following errors and warnings

2019-08-21T10:56:59.1480862Z ##[error]Failed to deploy web package to IIS website.
2019-08-21T10:56:59.1492670Z ##[warning]Can\'t find loc string for key: Trytodeploywebappagainwithrenamefileoptionselected
2019-08-21T10:56:59.1493093Z ##[warning]Trytodeploywebappagainwithrenamefileoptionselected
2019-08-21T10:56:59.1493421Z ##[error]Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'DemoWebApp.dll' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
Error count: 1.

I have configured the appOffline rule in the publishing profile (.pubxml) and add the EnableMSDeployAppOffline element to the PropertyGroup like this:

<PropertyGroup>
  <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
</PropertyGroup>

As described in More Information’s learn more URL http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.

Still it is failed to deploy web package to my local IIS website with the same errors and warnings.

When I trying to redeploy manually few times then it is working successfully other wise failed with same errors and warnings. Because I think the file is locked for some time in my local machine process.

It is also working successfully when I manually delete all the files from IIS release folder with that locked file.

Needs help, the file is locked by any one local process. I couldn’t find that local process. I couldn’t figure out the issue. I also don’t know if I found that process any how then how to figure out the issue. Is this just local issue?

Can anyone help me out?

like image 227
Sulay Joshi Avatar asked Nov 15 '25 20:11

Sulay Joshi


1 Answers

Recycle the application pool immediately before your 'Deploy IIS App' task. Add a 'WinRM - IIS Web App Management' task to you release pipeline. Set the Configuration type to 'IIS Application Pool', set the 'Action' to Recycle, and type in the app pool name in the 'Application pool name' field.

The recycle should unlock the dll and allow it to be deleted and replaced in the deployment step.

like image 123
Clinton Avery Avatar answered Nov 18 '25 19:11

Clinton Avery