在msdeploy中指定项目名称

发布于 2024-10-18 14:23:41 字数 863 浏览 4 评论 0原文

我在一个解决方案中有两个 Web 项目,我想使用 msbuild 和 WebDeploy 来部署它们(这是通过 CI 服务器发生的)。

目前,我正在运行命令行:

C:\ProjectFolder>msbuild <solution>.sln
    /p:Configuration=<Release>
    /p:OutputPath=bin
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>
    /p:MSDeployPublishMethod=WMSVC

这将按预期部署一个项目。但我怎样才能部署另一个呢?在这个命令行中我没有指定项目名称 - 为什么它选择一个项目来部署另一个项目?

理想情况下,我能够使用相同的命令部署两个项目,例如

...

    /p:Project=Project1
    /p:DeployIisAppPath=<SiteName>/Project1
    /p:Project=Project2
    /p:DeployIisAppPath=<SiteName>/Project2

但我怀疑这是可能的。或者,我只想知道如何在命令行中指定项目名称。

I've got two web projects in one solution, and I'd like to deploy them both using msbuild and WebDeploy (this happens through a CI server).

Currently, I'm running a command line:

C:\ProjectFolder>msbuild <solution>.sln
    /p:Configuration=<Release>
    /p:OutputPath=bin
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>
    /p:MSDeployPublishMethod=WMSVC

This deploys one project, as expected. But how can I deploy the other as well? There's nowhere in this command line where I specified a project name - why did it choose one project to deploy over the other?

Ideally, I'd be able to deploy two project with the same command, something like

...

    /p:Project=Project1
    /p:DeployIisAppPath=<SiteName>/Project1
    /p:Project=Project2
    /p:DeployIisAppPath=<SiteName>/Project2

But I doubt that's possible. Alternatively, I just want to know how to specify a project name in the command line.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

記憶穿過時間隧道 2024-10-25 14:23:41

我认为最好将单个调用分成三个:
- 构建 sln;
- 部署站点1;
- 部署站点2;

msbuild.exe <solution>.sln
    /p:Configuration=<Release>
    /p:OutputPath=bin

msbuild.exe project1dir\proj1.csproj
    /p:Configuration=<Release>
    /p:OutputPath=<Path to common bin>
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>/Project1
    /p:MSDeployPublishMethod=WMSVC

msbuild.exe project1dir\proj2.csproj
    /p:Configuration=<Release>
    /p:OutputPath=<Path to common bin>
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>/Project2
    /p:MSDeployPublishMethod=WMSVC

I think it would be better to divide the single call to three:
- Build sln;
- Deploy site1;
- Deploy site2;

msbuild.exe <solution>.sln
    /p:Configuration=<Release>
    /p:OutputPath=bin

msbuild.exe project1dir\proj1.csproj
    /p:Configuration=<Release>
    /p:OutputPath=<Path to common bin>
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>/Project1
    /p:MSDeployPublishMethod=WMSVC

msbuild.exe project1dir\proj2.csproj
    /p:Configuration=<Release>
    /p:OutputPath=<Path to common bin>
    /p:DeployOnBuild=True
    /p:DeployTarget=MSDeployPublish
    /p:MsDeployServiceUrl=https://<ServerUrl:port>/msdeploy.axd
    /p:username=<user>
    /p:password=<password>
    /p:AllowUntrustedCertificate=True
    /p:DeployIisAppPath=<SiteName>/Project2
    /p:MSDeployPublishMethod=WMSVC
讽刺将军 2024-10-25 14:23:41

如果从项目的根文件夹运行命令行,并且不指定要生成的文件,则 msbuild 应自动选择该文件夹中的项目。

这将需要两个单独的命令行调用。

然后,您可以通过构建一个批处理文件来构建此批处理文件,该批处理文件依次 cd 到每个文件夹并单独运行 msbuild,或者同样为触发每个构建的 msbuild 构建您自己的 proj 文件。

抱歉,我目前无法在手机上制作示例!

If you run the command line from the projects' root folder(s), and don't specify a file to build, msbuild should automatically select the project in that folder.

This will require two separate command line calls, tho.

You can then build on this by building a batch file that cd's to each of the folders in turn and runs msbuild separately, or equally build your own proj file for msbuild that triggers each build.

Sorry I can't craft an example at the moment tho-on a phone!

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