简体   繁体   中英

Can I control Port Number of Web Projects on TFS Build Server?

I have a unit test project and several web sites set up in my VS2010 solution. The web sites are used to host WCF services and are configured in the solution to use static port numbers, so that my test project will know the address to find them on. The web sites run under the VS development server, as opposed to IIS. This works great on my machine, as well as any other developer who runs the test project through VS. However, when the TFS build server tries to run the projects, it appears as though it is ignoring my static port numbers for the web sites.

I see errors in the event log indicating that the build server is trying to start up my web sites on port numbers that I did not indicate. I checked out the build directory and found the files for the web sites in directories with the test project assemblies, but there is no indication that the solution file is referenced anywhere, which is the mechanism that VS uses to contain the static port numbers. Is there a way for me to specify which ports the TFS build server will use to host my web sites from within the development web server when running a set of unit tests?

Also, if it sounds like I am trying to attack this issue in the wrong way, please let me know. This is my first experience with TFS build server, and I was really hoping to be able to have my automated unit tests be able to call my WCF services, somehow.

So, I solved this by calling WebDev.WebServer40.exe as a process within my test code to start up my web sites with the ASP.Net Development Server. This was very tricky, as I had to dynamically determine the location of the web site files at run time using a number of clues, since it is different between my local development environment and the build server. I really wish there were a way to just use the AspNetDevelopmentServerAttribute to specify a known port number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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