18
votes

I deploy website through Teamcity using webdeploy method:

web.csproj /P:Configuration=%env.Configuraton% /P:DeployOnBuild=True /P:DeployTarget=MSDeployPublish /P:MsDeployServiceUrl=%env.DeployServiceUrl% /P:AllowUntrustedCertificate=True /P:MSDeployPublishMethod=WMSvc /P:CreatePackageOnPublish=True /P:UserName=%env.DeployUserName% /P:Password=%env.DeployPassword%

The error I recieve constantly:

[MSDeployPublish] VSMSDeploy (35s) [VSMSDeploy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets(4196, 5): error ERROR_EXCEEDED_MAX_SITE_CONNECTIONS: Web deployment task failed. (The maximum number of connections for this site has been exceeded. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXCEEDED_MAX_SITE_CONNECTIONS.)

On Teamcity agent installed Visual Studio 2010 Express, .netf framework version: 4.0

5
Just to add my 2 cents: I retried and it worked. Sometimes cosmic rays just interfere. – Sebazzz

5 Answers

25
votes

I have fixed this problem by restarting the Web Management Service in Services.

1
votes

I investigated the problem on the both ends: hosting web server and build machine( Visual Studio 2010 Express SP1 installed from web installer) from which I initiate deployment. Restart of the team city server and agents (problem reproduced on 2 agents) didn't help. I've installed team city agent on local machine and deployed successfully from it. Then I compared successful and failed build logs. The interesting part is the source of the error:

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets

On my local machine (Visual Studio Ultimate 2010 with SP1) a have only

MSBuild\Microsoft\VisualStudio**v10**\Web\Microsoft.Web.Publishing.targets

so my quick solution was to test deployment using that method on build agents. I've replaced content of the

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\

with

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10\Web\

and that resolved the problem. I don't know why but deployment worked correctly on build agents previously.

1
votes

I've also come across this approach to allow an unlimited number of connections:

1.) Add the following registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]
"MaxSiteConnections"=dword:00000000

2.) Restart Web Management Service

Reference: Nicolas_nguyen1's comment on this Microsoft document

Source: How to limit webdeploy connection number, ERROR_EXCEEDED_MAX_SITE_CONNECTIONS

UPDATE

I was able to test this myself and it seemed like Web Deploy treated this value as literally "0" connections allowed, which resulted in this error occurring every time. So I set it to 0x7FFFFFFF (maximum for a 32 bit integer).

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]
"MaxSiteConnections"=dword:7FFFFFFF
0
votes

I have also encountered this error and I researched two ways to solve it. This is my original question, but I think this question is more easily searchable than mine, so I will repost my findings here to help others: https://stackoverflow.com/a/49140311/4228027

Method 1 - Limit connection via MSBuild

There is a way to limit how many thread MSBuild can use.

msbuild.exe mysln.sln /maxcpucount:3  

The "maxcpucount" limits the MSBuild threads, thus limit how many projects can be published at the same time. If it is not defined, MSBuild will actually use up to the number of processors on the computer.

Reference: https://msdn.microsoft.com/en-us/library/bb651793.aspx

Method 2 - Lift limit on the server

Add a registry value to the server

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]

"MaxSiteConnections" (DWORD Value) : 0

Then restart "Web Management Service".

When you set the registry value to 0, it means unlimited connection.

Reference: Nicolas_nguyen1's comment in this Microsoft document

0
votes

I had this same issue today on a new TeamCity build I was setting up. Builds are using Web Deploy to publish two MVC4 applications to test servers on the local network on a nightly schedule.

In my case, the error was due to having the "Trigger build on all enabled and compatible agents" option checked on the build's Schedule Trigger in TeamCity. We have four build agents and having that option checked was starting four builds at the same time. Two of the builds succeeded and two failed with the ERROR_EXCEEDED_MAX_SITE_CONNECTIONS error.