如何使用 web 部署在具有不同端口的本地主机上部署多个站点

发布于 2024-11-17 05:42:30 字数 855 浏览 5 评论 0原文

我有一个包含多个集成测试项目和一个 Web 应用程序项目的解决方案。运行测试时,每个集成项目都会连接到 Web 应用程序。我希望每个测试项目都使用自己的数据库连接访问该网站。我一直在尝试使用 Visual Studio 中内置的 Web 部署功能。但是,我无法弄清楚需要添加到创建的部署包和/或测试项目的构建后事件中,以在部署时声明网站的绑定端口。例如,我希望集成项目 A 创建并访问位于 http://localhost:83 的网站和集成项目 B创建并访问位于 http://localhost:82 的网站。有人可以解释一下:

  1. 部署包需要做什么吗?
  2. 部署包时,我需要在集成项目的构建后事件中添加哪些内容,以便在构建项目时在正确的端口创建网站?

更新: 我想将同一个站点部署到我的计算机上的两个不同位置,以便我可以同时运行两组集成测试。

更新2: 我研究了 Web 部署工具,它允许您指定参数来修改从命令行调用它时部署的内容。但是我发现文档非常混乱。 http://technet.microsoft.com/en-us/库/dd568968(WS.10).aspx

更新 3: 我希望它们是两个不同的网站,每个网站都指向自己的数据库。如果可能的话,我想要一个可以使用 msdeploy 部署的单个包。然后将在每个集成测试项目的构建后事件中调用它。我想从集成项目的构建后脚本中指定连接字符串和部署位置。

I have a solution that contains multiple integration test projects and one web application project. each integration project connects to the web application when running the tests. I would like for each test project to access the website with its own database connection. I have been trying to use the web deploy functionality built into visual studio. However I have been unable to figure out what I need to add to either the deployment package that is created and/or the post build event for the test projects to declare the binding port for the website when deployed. For example, I want integration project A to create and access the website located at http://localhost:83 and integration project B to create and access the website located at http://localhost:82. Could someone please explain:

  1. Is there anything I need to do the deployment package ?
  2. What do I need to add to my post-build events for my integration projects when deploying the package, so that the website is created at the correct port when building the project?

Update:
I'm wanting to deploy the same site to two different locations on my machine so that I can run both sets of integration tests at the same time.

Update 2:
I have researched the web deploy tool and it allows you to specify parameters that modify what is deployed when you call it from the command line. However I have found the documentation very confusing. http://technet.microsoft.com/en-us/library/dd568968(WS.10).aspx

Update 3:
I expect these to be two different websites, each pointing to there own database. If possible I would like a single package that can be deployed using msdeploy. Which will then be called in a post build event from each of the integration test projects. I would like to specify the connection string and deployment location from the post build script of the integration project.

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

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

发布评论

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

评论(3

清风疏影 2024-11-24 05:42:30

您可以尝试使用 Visual Studio 中包含的 webdev.server 。 VisualStudio 在调试时使用它来启动网络服务器。这样您就可以在所需端口启动网络服务器(如果当前未使用该端口)。
我制作了一个bat文件来更改一些选项。
检查一下。

::bat 文件开头

cd C:\Program Files\Common Files\microsoft shared\DevServer\10.0\
WebDev.WebServer40.exe /port:80 /path:"C:\PATHTOYOURWEBPROJECT" /vpath:"/NAMEOFYOURWEBPROJECT"

::bat 文件结尾

您可以访问: http://localhost:80

我使用的是webserver40,但是如果你没有net.4或vs2010你可以尝试找webserver[ xx version].exe

我希望这会有所帮助,对于我蹩脚的英语感到抱歉。

you can try with webdev.server included in visual studio. VisualStudio use this for start a webserver when you debug. With this you can start a webserver in the desire port (if the port is not used currently).
I made a bat file for change some options.
check it.

::Begin of bat file

cd C:\Program Files\Common Files\microsoft shared\DevServer\10.0\
WebDev.WebServer40.exe /port:80 /path:"C:\PATHTOYOURWEBPROJECT" /vpath:"/NAMEOFYOURWEBPROJECT"

::End of bat file

You can acces in: http://localhost:80

I use the webserver40, but if you don't have net.4 or vs2010 you can try to find webserver[ xx version].exe

I hope that this will be helpful, and sorry for my broken english.

习惯成性 2024-11-24 05:42:30

首先,你处理这个问题的方式是错误的。

>我希望每个测试项目都能访问该网站及其
自己的数据库连接。

谁在创建数据库连接?您的网站或测试项目?为了让你的问题的其余部分有意义,我认为它是网站(否则,项目 A 和项目 B 无法共享开箱即用的连接)。

如果您的网站正在建立连接,除非您正在缓存或拥有静态连接,否则当每个请求在新的网络上运行您的网站时,都会建立一个新的连接。线。另一个更简单的替代方案是获取查询参数并基于该参数启动新连接。如果您从调用者处获取它,您还可以使用它进行更详细的日志记录。

Web 部署项目用于部署到集成服务器,因此这意味着您无法通过 http://localhost... 访问它们,而是通过服务器的完整 FQDN 访问它们。

最重要的是,http://localhost:82/myApphttp://localhost:83/myApp 是两个不同的站点(除非您从其中一个站点重定向到另一个站点)其本身可能会导致其他问题)运行相同的代码库。

话虽如此,您需要部署网站两次,然后您所需要做的就是更改项目 A 和 B 中的配置/设置条目以将它们指向不同的站点。

希望这是有道理的。

First off, you're approaching this the wrong way.

> I would like for each test project to access the website with its
own database connection.

Who is creating the DB connection? Your web site or the test project? For rest of your question to make sense, I presume its the web site (otherwise, Project A and Project B cannot share a connection out of the box).

If your website is making the connection, unless you're caching or having a static connection, there will be a new connection made as each request runs your your site on a new thread. Another simpler alternative is to take a query param and initiate a new connection based on that. If you seed it off the caller, you can also use it for more detailed logging.

Web Deployment projects are meant for deploying to integration servers, so that means you cannot access them by http://localhost... but the full FQDN of the server.

Most importantly, http://localhost:82/myApp and http://localhost:83/myApp are two different sites (unless you redirect from one of them to another one which in itself can cause additional issues) running the same codebase.

Having said that, you would then need to deploy your website twice and then all you need is to change the config/settings entry in Project A and B to point to these to different sites.

Hope this makes sense.

水水月牙 2024-11-24 05:42:30

您可以定义虚拟主机配置。
请参阅本指南了解更多信息。

http://docs.jboss.org/jbossas/guides /webguide/r2/en/html/ch07.html

You can define virtual host configuration.
Refer this guide for more information.

http://docs.jboss.org/jbossas/guides/webguide/r2/en/html/ch07.html

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