Get MSDeploy to skip specific folders and file types in folders as CCNet task

I want MSDeploy to skip specific folders and file types in other folders when using synchronization. I am currently using CCNet to invoke MSDeploy using the sync verb to select websites from assembly to an intermediate server. Since the destination has files created by the application / user, downloaded files, etc., I need to exclude certain folders from the destination . There are also manifest files created by the site that should remain at the destination.

At the moment, I used -enableRule:DoNotDeleteRule , but this leaves the obsolete files in the destination.

 <exec> <executable>$(MsDeploy)</executable> <baseDirectory>$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\</baseDirectory> <buildArgs>-verb:sync -source:iisApp="$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\" -dest:iisApp="$(website)/$(websiteFolder)" -enableRule:DoNotDeleteRule</buildArgs> <buildTimeoutSeconds>600</buildTimeoutSeconds> <successExitCodes>0,1,2</successExitCodes> </exec> 

I tried using the skip operation, but ran into problems. I originally dropped the DoNotDeleteRule and replaced it with (several) skip

 <exec> <executable>$(MsDeploy)</executable <baseDirectory>$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\</baseDirectory> <buildArgs>-verb:sync -source:iisApp="$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\" -dest:iisApp="$(website)/$(websiteFolder)" -skip:objectName=dirPath,absolutePath="assets" -skip:objectName=dirPath,absolutePath="survey" -skip:objectName=dirPath,absolutePath="completion/custom/complete*.aspx" -skip:objectName=dirPath,absolutePath="completion/custom/surveylist*.manifest" -skip:objectName=dirPath,absolutePath="content/scorecardsupport" -skip:objectName=dirPath,absolutePath="Desktop/docs" -skip:objectName=dirPath,absolutePath="_TempImageFiles"</buildArgs> <buildTimeoutSeconds>600</buildTimeoutSeconds> <successExitCodes>0,1,2</successExitCodes> </exec> 

But this leads to the following:


Error: source (iisApp) and destination (contentPath) are not compatible for this operation.
Number of errors: 1.

So, I changed from iisApp to contentPath and instead of dirPath, absolutePath is just a Directory like this:

 <exec> <executable>$(MsDeploy)</executable <baseDirectory>$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\</baseDirectory> <buildArgs>-verb:sync -source:contentPath="$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\" -dest:contentPath="$(website)/$(websiteFolder)" -skip:Directory="assets" -skip:Directory="survey" -skip:Directory="content/scorecardsupport" -skip:Directory="Desktop/docs" -skip:Directory="_TempImageFiles"</buildArgs> <buildTimeoutSeconds>600</buildTimeoutSeconds> <successExitCodes>0,1,2</successExitCodes> </exec> 

and this gives me an error: Invalid characters in the path:

<buildresults>
Info: Add MSDeploy.contentPath (MSDeploy.contentPath).
Info: Adding contentPath (C: \ WWWRoot \ MySite
-skip: Directory = assets
-skip: Directory = overview
-skip: Directory = content / scorecardsupport
-skip: Directory = Desktop / documents
-skip: Directory = _TempImageFiles)
. Info: adding dirPath (C: \ WWWRoot \ MySite
-skip: Directory = assets
-skip: Directory = overview
-skip: Directory = content / scorecardsupport
-skip: Directory = Desktop / documents
-skip: Directory = _TempImageFiles)
. </buildresults>

<buildresults>
Error: Invalid characters in the path.
Number of errors: 1.
</buildresults>

So, I need to know how to configure this task so that the links to the folders are not deleted as a result of their synchronization and that the * .manifest and * .aspx files in the completion / user folders are also skipped.

+4
source share
2 answers

The problem with this was ... line break! Where would I split each -skip directive into a new line that caused invalid characters in the path. Running all inline skipping directives resolved the following:

 <exec> <executable>$(MsDeploy)</executable> <baseDirectory>$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\</baseDirectory> <buildArgs>-verb:sync -source:contentPath="$(ProjectsDirectory)$(projectName)$(ProjectsWorkingDirectory)\Website\" -dest:contentPath="C:\WWWRoot\$(websiteFolder)" -skip:Directory="assets" -skip:Directory="_TempImageFiles" -skip:objectName=dirPath,absolutePath="\\Desktop\\Docs" </buildArgs> <buildTimeoutSeconds>600</buildTimeoutSeconds> <successExitCodes>0,1,2</successExitCodes> </exec> 
+5
source

Take a look at this MSDN article entitled Website Deployment: Excluding Files and Folders Through a Web Application Project File . In particular, the section "Exclusion of certain files / folders." This will stop mappings of directories, files, and files / files that will be included as contents in the deployment package, and will also be ignored at the destination during deployment.

However, I would take a step back and ask why these files exist in your web project in the first place. How I processed user-uploaded content in IIS by adding a virtual directory to my web application. The contents of virtual directories (and the provision of vdir itself) are ignored when synchronizing in the deployment web package. It also gives you the advantage of placing the client’s content directory anywhere that has a number of advantages (i.e. a larger disk drive, preventing denial of service by dishonest users who are trying to fill your hard drive with garbage data, etc.) ,

+1
source

All Articles