简体   繁体   English

MSDeploy - sync命令将文件复制到iis app的子文件夹

[英]MSDeploy - sync command to copy files to subfolder of iis app

I want to perform a post-build step to copy some files into a website folder using MSDeploy. 我想执行一个后期构建步骤,使用MSDeploy将一些文件复制到网站文件夹中。

Eventually I'll be doing this to a remote location (specifying computerName , userName switches etc.), but for now I'm running it locally: 最终我将这个到远程位置(指定computerNameuserName开关等),但是现在我在本地运行它:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
   -AllowUntrusted -verb:sync 
   -source:dirPath="D:\files_to_copy" 
   -dest:iisApp="My Website Name"

This works, but it removes all contents of the website folder and replaces them with the contents of "D:\\files_to_copy" (as you might expect!). 这有效,但它会删除网站文件夹的所有内容,并将其替换为“D:\\ files_to_copy”的内容(正如您所料!)。 So I was wondering how I use this simply copy to a subfolder within the site? 所以我想知道我如何使用这个简单的副本到网站内的子文件夹?

I've tried -dest:iisApp="My Website Name/my_subfolder" but this just creates a new IIS app called "my_subfolder" nested within the existing IIS app. 我已经尝试了-dest:iisApp="My Website Name/my_subfolder"但这只会创建一个名为“my_subfolder”的新IIS应用程序嵌套在现有的IIS应用程序中。

There are providers other than iisApp, maybe dirPath is the one you want for -dest aswell?: 有除iisApp之外的提供者 ,也许dirPath是你想要的-dest吗?:

  • dirPath : The dirPath provider synchronizes directory content. dirPath :dirPath提供程序同步目录内容。
  • filePath : The filePath provider synchronizes individual files. filePath :filePath提供程序同步单个文件。
  • iisApp : The iisApp provider synchronizes directory content to a folder and marks the folder as an application. iisApp :iisApp提供程序将目录内容同步到文件夹,并将该文件夹标记为应用程序。
  • contentPath : The contentPath provider synchronizes Web site content. contentPath :contentPath提供程序同步网站内容。

Anders's answer above provides the correct information, but the full code I used to successfully carry this out is as follows: Anders上面的回答提供了正确的信息,但我用来成功实现这一目的的完整代码如下:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
  -AllowUntrusted -verb:sync 
  -source:contentPath="D:\files_to_copy" 
  -dest:contentPath="My Website Name\my_new_folder"

Adding a single file to the root of the site (for example robots.txt ) can be done using the following: 可以使用以下方法将单个文件添加到站点的根目录(例如robots.txt ):

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
  -AllowUntrusted -verb:sync 
  -source:contentPath="D:\my_folder\robots.txt" 
  -dest:contentPath="My Website Name\robots.txt"

Hopefully this is a useful example for others in the future. 希望这对未来的其他人来说是一个有用的例子。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM