使用MSDeploy一个可执行文件复制到服务器,并再运行相同的可执行文件、服务器、MSDeploy

2023-09-03 11:32:44 作者:绝世风光 ▎Circular。

我有MSDeploy / WebDeploy工作请客来更新我的W​​eb应用程序 - 这样可以解决大约90%的我的部署问题,因为我已经有了创办至今的事情

I've got MSDeploy/WebDeploy working a treat to update my web applications - this resolves about 90% of my deployment issues for the things I've got set up so far.

我想这样做,除了是一个可执行文件复制 - 文件夹务实的内容 - 到服务器,然后运行一个可执行文件(这确实架构更新)

What I would like to do, in addition, is to copy an executable - pragmatically the contents of a folder - to the server and then to run that executable (which does schema updates).

我可以看到,这应该是可能的,但我奋力把拼在一起(这显然是一个边缘的情况下)。

I can see that this ought to be possible, but I'm struggling to put the pieces together (this is clearly an edge case).

具体做法是:

我宁愿不可执行文件(文件夹)复制到web目录。 我需要考虑运行可执行的结果(有用返回一个失败状态,但如果显著这将让泛起部署后测试)

与其他因素一样,因此,具体是什么命令,什么样的顺序 - 如果我能找到一个模式,我可以让它工作,但我在努力制定出一个模式

As much as anything therefore, what specific commands in what order - if I can find a pattern I can make it work but I'm struggling to work out a pattern

注:

它确实发生了,我认为我可以在文件夹复制到web目录,运行code,然后再删除该文件夹,但我不舒服这一点,在任何情况下,它会更好,有code,适用于服务器的部署后。

It does occur to me that I could copy the folder to the web directory, run the code and then delete the folder again but I'm uncomfortable with this and in any case it would be better to have the code available on the server post deployment.

其还值得一提的是,我真的的真正的幸福与我保持数据库架构因此,事实上,这就是可执行文件做的是附带问题的办法

Its also worth noting that I am really really happy with the way I maintain database schemas so the fact that that's what the executable is doing is incidental to the question

推荐答案

网络部署实际上提供了不少选择这里。其中选择一种你选择取决于你想要多少东西装进一个命令。

Web Deploy actually offers quite a few options here. Which options you choose kind of depends on how many things you want to put into one command.

要得到文件的文件夹转移到了目的地,你可以使用Web部署的的 dirPath 提供商做复制到您选择的位置。要复制单个文件,您可以使用文件路径提供商。如果你复制源有许多小文件,Web部署实际上比ROBOCOPY更好的性能在网络上(参见我的博客文章的网络部署与使用Robocopy )。

To get a folder of files over to the destination, you could use the Web Deploy’s dirPath provider to do the copying to the location of your choice. To copy an individual file, you can use the filePath provider. If your copy source has many small files, Web Deploy is actually more performant than RoboCopy over a network (see my blog post Web Deploy vs. Robocopy).

要运行复制到目标服务器的命令文件,可以使用的 runCommand 提供商。 (这是一个重要的,我肯定会读了它。)

To run the command file that you copied to the destination server, you can use the runCommand provider. (This is an important one, I would definitely read up on it.)

请注意,在这一点上,我们正在谈论至少有两个独立的Web部署命令,不包括任何的通常网络部署运营的像部署网站或Web服务器。

Note that at this point we’re talking about at least two separate Web Deploy commands, not counting any of the "usual" Web Deploy operations like deploying a website or web server.

然而,如果你的目标是实现一切都在一个网络部署的操作,您可以使用的清单提供商。创建一个自定义清单文件,指定了一系列网络部署提供者操作将依次执行的。然后,在网络部署命令,指出该清单提供给定制清单文件。有关此方法的详细信息,请参见创建和同步自定义清单

However, if your goal is to achieve everything in one Web Deploy operation, you can use the manifest provider. Create a custom manifest file that specifies a series of Web Deploy provider operations that will execute in turn. Then, in the Web Deploy command, point the manifest provider to the custom manifest file. For more information on this approach, see Creating and Synchronizing a Custom Manifest.

如果你使用的清单提供者,你可以指定 dirPath 供应商清单文件中复制过来的文件或文件,然后在指定的 runCommand 提供商下一行实际运行,你复制过来的可执行文件。

If you do use the manifest provider, you could specify the dirPath provider in the manifest file to copy the file or files over, and then specify the runCommand provider on a subsequent line to actually run the executable that you copied over.

最后,这种方法一步短的使用清单文件中是使用 preSYNC 和/或 postSync 命令行开关运行的命令前或实际网络部署后,运行目标服务器发生。您可以在 preSYNC 和 postSync 上的网络部署操作设置页。

Finally, an approach one step short of using a manifest file is to use the preSync and/or postSync command line switches to run a command on the destination server before or after the actual Web Deploy operation takes place. You can find more information on preSync and postSync on the Web Deploy Operation Settings page.

所有被引用的页面有语法的例子,因此,应该帮助。

All of the pages referenced have syntax examples, so that should help.