Reputation: 4519
I have a folder on my web application which is used to store user uploads, i.e. profile pictures, that sort of thing.
When I use WebDeploy, there is an option for "Leave extra files (Do not delete)" which when ticked makes sure that the profile pictures are not deleted.
What I am seeking is a way to ensure that even if that is unticked, a certain folder is safe from deletion. The reason for this being that I don't want another developer to accidentally disable the feature in future. Or me for that matter.
Any ideas? I have seen a few similar questions on here but nothing seems to be relevant to Visual Studio 2010, which is what I am using.
Upvotes: 1
Views: 3396
Reputation: 84724
(I assume you're using publish profiles as per Visual Studio 2010 w/ the Azure SDK or Visual Studio 2012 RTM. If you're not, create an MSBuild file called ProjectName.wpp.targets
in the project root and put content in that instead)
You can disable all forms of deletes by setting <SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
in your publish profile (equivalent to the checkbox you mentioned).
To skip a particular directory, a comment on this question implies you can use the following syntax:
<ItemGroup>
<ExcludeFoldersFromDeployment Include="FolderName" />
</ItemGroup>
But I've never seen that before and haven't tested it. Failing that, you can specify an explicit skip rule. "FolderName" is being skipped here - keep in mind that AbsolutePath
is a regex:
<MsDeploySkipRules Include="SkipFolderName">
<SkipAction>Delete</SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>FolderName$</AbsolutePath>
</MsDeploySkipRules>
NOTE: There are some scenarios in which skip rules don't work when using Visual Studio unless you also set UseMsDeployExe
to true
Upvotes: 3
Reputation: 1269
You can set specific rules on the target machines using the msdeploy.exe.configsettings file, there is also a msdeploy.exe.configsettings.example file in the same folder. The file is located in %program files%\IIS\Microsoft Web Deploy - folder see Web Deploy Rules
You can set Rules and skipDirectives here and enable whether they are defaulted so you get your expected default behaviour.
Upvotes: 2