如何通过代理连接到TFS编程? [英] How to connect to TFS via proxy programmatically?
问题描述
在我的公司,我们最近成立了一个TeamFoundation代理我们的TeamFoundationServer。我写了一个C#应用程序,连接到TFS查询各种东西。现在,我希望应用程序以支持在TFS代理连接为好。由于我没有真正熟悉TFS,我有一些困难。理想情况下,我希望应用程序只是知道TFS代理,并有它的行为就像正常的TFS。 ?这甚至可能
At my company we have recently set up a TeamFoundation proxy to our TeamFoundationServer. I have written a C# app, that connects to the TFS to query various things. Now, I want the app to support connection over the TFS proxy as well. As I am not really familiar with TFS, I am having some difficulties. Ideally, I want the application to only "know" the TFS proxy and have it act just like the normal TFS. Is this even possible?
我做的是这样的:
TfsTeamProjectCollection projects =
new TfsTeamProjectCollection(new Uri(serverUriString,
new NetworkCredential(username, password, domain));
这工作正常,如果 serverUriString
是TFS(例如HTTP:// MyTfs:8080)。当我这代与TFS代理(如HTTP:// MyTfsProxy:8081),我得到一些不确定的 TeamFoundationServiceUnavailableException
,其中在最后它指出,发生了HTTP 404错误404。没有多大意义,我,我能够ping服务器,我可以从浏览器连接到它和Visual Studio acceppts它。我需要设置为TFS和代理的连接?如果是的话,我该怎么做呢?
This works fine if serverUriString
is the TFS (e.g. "http://MyTfs:8080"). When I substitute this with the TFS proxy (e.g. "http://MyTfsProxy:8081") I get some unspecific TeamFoundationServiceUnavailableException
, where at the end it states that a http 404 error occurred. The 404 doesn't make much sense to me, I am able to ping the server, I can connect to it from the browser and Visual Studio acceppts it as well. Do I need to set a connection to the TFS AND the proxy? If yes, how do I do that?
推荐答案
该AddProxy()用于与TFS服务器注册的代理服务器列表的方法,以便客户端可以自动检测和放大器;使用代理服务器。
The AddProxy() method is used to register a list of proxy servers with the TFS server, so that clients can automatically detect & use a proxy server.
如果你只是想配置您的客户端使用代理服务器,没有财产做到这一点。你必须设置一个注册表项或一个未公开的环境变量
If you just want to configure your client to use a proxy server, there is no property to do this. You have to set a registry key or an undocumented environment variable.
有关TFS2008客户端,注册表项是:
For TFS2008 clients, the registry key is:
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\SourceControl\Proxy]
"Enabled"="True"
"Url"="http://someproxy:8081"
有关TFS2010客户,该注册表项
For TFS2010 clients, the registry key is:
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Proxy]
"Enabled"="True"
"Url"="http://someproxy:8081"
在任一TFS版本,您可以设置无证环境变量:
In either TFS version, you can set the undocumented environment variable:
System.Environment.SetEnvironmentVariable("TFSPROXY",http://someproxy:8081);
这篇关于如何通过代理连接到TFS编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!