简体   繁体   English

保护IIS文件夹不被WebDeploy删除

[英]Protect IIS folder from being deleted by WebDeploy

I have a folder on my web application which is used to store user uploads, ie profile pictures, that sort of thing. 我的Web应用程序上有一个文件夹,用于存储用户上传的内容(即个人资料图片)。

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. 当我使用WebDeploy时,有一个“保留额外的文件(不要删除)”选项,勾选该选项可确保不删除个人资料图片。

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. 我在这里看到了一些类似的问题,但似乎与我正在使用的Visual Studio 2010无关。

(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) (我假设您正在使用带有Azure SDK或Visual Studio 2012 RTM的Visual Studio 2010中的发布配置文件。如果不是,则在项目根目录中创建一个名为ProjectName.wpp.targets的MSBuild文件,并将内容放入其中代替)

You can disable all forms of deletes by setting <SkipExtraFilesOnServer>true</SkipExtraFilesOnServer> in your publish profile (equivalent to the checkbox you mentioned). 您可以通过在发布配置文件中设置<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>来禁用所有形式的删除(相当于您提到的复选框)。

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: 在这里跳过“ FolderName”-请记住, AbsolutePath是一个正则表达式:

<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 注意:某些情况下 ,除非您将UseMsDeployExe设置为true否则在使用Visual Studio时跳过规则不起作用。

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. 您可以使用msdeploy.exe.configsettings文件在目标计算机上设置特定规则,同一文件夹中也有一个msdeploy.exe.configsettings.example文件。 The file is located in %program files%\\IIS\\Microsoft Web Deploy - folder see Web Deploy Rules 该文件位于%program files%\\ IIS \\ Microsoft Web Deploy-文件夹中,请参阅Web部署规则

You can set Rules and skipDirectives here and enable whether they are defaulted so you get your expected default behaviour. 您可以在此处设置Rule和skipDirectives并启用它们是否为默认值,以便获得预期的默认行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MSBuild / WebDeploy - 如何防止它删除文件夹及其内容 - MSBuild/WebDeploy - How to prevent it from deleting a folder and its contents IIS我的网站文件夹已删除 - IIS My Web Sites Folder Deleted 保护文件夹免受外部请求 - Protect folder from external requests 如何从IIS 8.5默认网站下的先前删除的Web应用程序中删除文件夹? - How to delete folder from previously deleted Web App under IIS 8.5 Default Web Site? 使用Build Definitions将WebDeploy从TFS部署到IIS站点,其中包含用户更改的文件 - WebDeploy from TFS using Build Definitions to IIS site containing files changed by users 在VS2012中使用发布Web部署时,如何防止删除文件夹? - How to prevent a folder from being deleted when using Publish Web Deploy in VS2012? 如何保护ASP.NET MVC / IIS应用程序免受复制? - How to protect ASP.NET MVC/IIS application from copying? IIS文件夹被添加到可点击的行链接引导程序 - IIS Folder being added to clickable row link bootstrap 发布到服务器时,如何保护javascript变量不受操纵? - How to protect javascript variables from being manipulated when posting to server? WebDeploy到Azure oca失败:站点文件夹访问权限不足 - WebDeploy to Azure oca failing: Insufficient acces to site folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM