I'm deploying my ASP.NET-MVC3 application to an IIS7 server.
Publishing to web works fine if I check "Leave extra files on destination (do not delete)".
If the checkbox is not checked, it usually fails with this error:
Error 65 Web deployment task failed.((2013.07.10. 17:06:09) An error occurred when the request was processed on the remote computer.)
(2013.07.10. 17:06:09) An error occurred when the request was processed on the remote computer.
An error was encountered when processing operation 'Delete File' on 'App_tracelog.svclog'.
The error code was 0x80070020.
The process cannot access 'D:\WebSites\app\Admin\App_tracelog.svclog' because it is being used by another process. 0 0 AdminApp
Clearly the tracelog cannot be deleted as it is currently written by the application.
I don't want to leave all files on the server on the deploy, so I first thought that switching my application off, deploy, and switching it on would be a good solution. It works, but I haven't been able to do it automatically (on pressing publish). (Is there a way?)
I later realized, that deleting the tracelog is bad practice. The log should be preserved, it is there so I can later access and read it.
I want to delete nearly everything from the folder I deploy to, except my logs, and some of my backed up files. Is there a way to to force the deploy to automatically clean that folder from files except a few (with the extension .tracelog, .bak, .log, etc)?
You can do so in the following manner:
create YourWebProjectName.wpp.targets file next to you the project file with the following content:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <MsDeploySkipRules Include="SkipXMLFiles"> <SkipAction></SkipAction> <ObjectName>filePath</ObjectName> <AbsolutePath>$(_DestinationContentPath)\\*.xml</AbsolutePath> <Apply>Destination</Apply> <XPath></XPath> </MsDeploySkipRules> </Project>
You can have a look at this answer for more details on how to to have a more grained control on which folders/files get deleted/synchronised.
NB: VisualStudio tends to cache wpp.targets files so if you use VS to esecute your publish, I suggest you to restart VS after you modify them.
User contributions licensed under CC BY-SA 3.0