0
votes

I have a build step on TeamCity, that builds a project file and deploys the project to a network location. //server/system/Web

When the web folder does not exist, the deployment works fine, however, if the web folder already exists, the web folder is just deleted and the build fails.

Is there a flag I need to set, so msbuild just replaces the content, if there is anything there. I have also considered a powershell script that removes all content from the folder, before deploying, is this a viable solution?

LOG:

[12:20:18][MSBuild output] CopyAllFilesToSingleFolderForMsdeploy:

[12:20:18][MSBuild output] Creating directory "\server\system\web".

[12:20:18][MSBuild output] Copying all files to temporary location below for package/publish:

[12:20:18][MSBuild output] \server\system\web.

[12:20:18][MSBuild output] Copying bin\Dokumentproduksjon.Web.dll to \server\system\web\bin\Dokumentproduksjon.Web.dll.

[12:20:18][MSBuild output] Create Folder \server\system\web\bin failed. Access to the path '\server\system\web\bin' is denied.

[12:20:18][MSBuild output] Done Building Project "C:\TeamCity\buildAgent\work\ac656796ad82c0\Dokumentproduksjon.Web\Dokumentproduksjon.Web.csproj.teamcity" (Build;Package target(s)) -- FAILED.

[12:20:18][MSBuild output]

[12:20:18][MSBuild output] Build FAILED.

1

1 Answers

0
votes

Is this a deployment to production or into a testing environment?

If it's production, is it possible that you are serving up the content and that it is therefore locked? Is IIS / Apache serving up the content?

If it's into a testing environment, the same could be true, have you verified it's not being hosted? Typically the ideal situation is to deploy to a clean Virtual Machine, ensuring that you are deploying as if it were a new environment. That will get you around the problem of the web folder existing already. If you do not have that luxury, then you want to run scripts first that make this environment mimic a clean environment, so yes, you would want a command to drop that folder. However, back to the comment earlier, if something has a file lock on that folder your command will fail as well.