使用 MSDeploy 将可执行文件复制到服务器,然后运行它

发布于 2024-12-21 14:00:49 字数 539 浏览 4 评论 0原文

我已经使用 MSDeploy/WebDeploy 来更新我的 Web 应用程序 - 这解决了我迄今为止设置的大约 90% 的部署问题。

此外,我想做的是将可执行文件(实际上是文件夹的内容)复制到服务器,然后运行该可执行文件(这会更新架构)。

我可以看到这应该是可能的,但我正在努力将各个部分组合在一起(这显然是一种边缘情况)。

具体来说:

  • 我不想将可执行文件(文件夹)复制到 Web 目录中。
  • 我需要考虑运行可执行文件的结果(对于返回失败状态很有用,尽管如果很重要,这将在部署后测试中抛出)

因此,无论什么具体命令,按什么顺序 - 如果我能找到一个我可以让它工作,但我正在努力找出一个模式


注释:

我确实想到我可以将文件夹复制到网络目录,运行代码,然后再次删除该文件夹但我对此感到不舒服,无论如何最好有部署后服务器上可用的代码。

还值得注意的是,我真的对维护数据库模式的方式感到非常满意,因此可执行文件正在做的事情这一事实对于这个问题来说是偶然的

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).

Specifically:

  • I'd rather not copy the executable (folder) into the web directory.
  • I need to consider the result of running the executable (be useful to return a failure status, though if significant this will get thrown up by post deployment tests)

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


Notes:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虫児飞 2024-12-28 14:00:49

Web Deploy 实际上在这里提供了相当多的选项。您选择哪些选项取决于您想要在一个命令中放入多少内容。

要将文件文件夹传输到目标,您可以使用 Web 部署的 dirPath 提供商将内容复制到您选择的位置。要复制单个文件,您可以使用文件路径 提供者。如果您的复制源有许多小文件,Web Deploy 实际上比网络上的 RoboCopy 性能更高(请参阅我的博客文章 Web 部署与 Robocopy)。

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

请注意,此时我们正在讨论至少两个单独的 Web 部署命令,不包括任何“常见”Web 部署操作,例如部署网站或网络服务器。

但是,如果您的目标是在一次 Web 部署操作中实现所有目标,则可以使用 清单 提供者。创建一个自定义清单文件,指定一系列将依次执行的 Web 部署提供程序操作。然后,在 Web 部署命令中,将清单提供程序指向自定义清单文件。有关此方法的详细信息,请参阅创建和同步自定义清单

如果您确实使用清单提供程序,则可以在清单文件中指定 dirPath 提供程序来复制一个或多个文件,然后在后续行中指定 runCommand 提供程序实际运行您复制的可执行文件。

最后,距离使用清单文件一步之遥的方法是使用 preSync 和/或 postSync 命令行开关在同步之前或之后在目标服务器上运行命令。发生实际的 Web 部署操作。您可以在 Web 部署操作设置 页面。

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

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.

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).

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.)

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.

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文