MSBuild appending MSDEPLOYAGENTSERVICE to the end of my URL - c#

I am trying to configure a build in TFS to deploy to our test box for continuous integration. The problem I'm having is that TFS wants to append the MSDEPLOYAGENTSERVICE to the end of my URL which is causing the deploy to return a socket error:
Retrying the sync because a socket error (10054) occurred. Retrying operation 'Serialization' on object sitemanifest (sourcePath).
Here are my MSBuild Arguments:
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=[ip address]:8172/MsDeploy.axd
/p:MSDeployPublishMethod=RemoteAgent
/p:CreatePackageOnPublish=True
The server is a Windows Server 2008 R2 64bit server with IIS 7.5. We have no problems using the publish feature of Visual Studio 2010 to deploy to the test box using the Url above. Any help would be much appreciated.

You don't need to specify MsDeploy.axd in your MsDeployServiceUrl. Also, I see you don't have a DeployIisAppPath value set. You should set it to the name of your website in IIS.
Below is an example from one of our CI builds.
/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=RemoteAgent
/p:MSDeployServiceUrl=http://[YOUR WEBSERVER URL]
/p:DeployIisAppPath="NAME-OF-WEBSITE-IN-IIS"

After a few days an tons of searching, I discovered the issue.
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=[ip address]/MsDeploy.axd
/p:MSDeployPublishMethod=WMSVC
/p:CreatePackageOnPublish=True
/p:DeployIisAppPath=[name of website in iis]
/p:AllowUntrustedCertificate=True
As it turns out, the publish method was the culprit. RemoteAgent cannot interpret the deploy correctly, which is why it fails to serialize. WMSVC is the appropriate setting for the publish method.

Related

Dotnet: Works in VSCode's OWN TERMINAL, but OMNISHARP: 'dotnet.exe' is not recognized

How is this possible?
I installed .net sdk 6.0.405: dotnet-sdk-6.0.405-win-x64.exe
I can in windows terminal and power shell run: dotnet --version: 6.0.405 ✅
I CAN ALSO IN VSCODE IN ITS BUILTIN TERMINAL, run: dotnet --version: 6.0.405 ✅✅
But in the OUTPUT tab, choosing OmniSharp Log from the dropdown, it says:
[ERROR] A .NET 6 SDK for x86_64 was not found. Please install the latest x86_64 SDK from ...
I switched vscode explorer settings to use external terminal.
And this terminal setting to command prompt:
Terminal › Integrated › Default Profile: Windows
The default profile used on Windows. This setting will currently be ignored if either terminal.integrated.shell.windows or terminal.integrated.shellArgs.windows are set.
I have dotnet in the PATH (and it works in terminals and in vscode's terminal)
I restarted vscode, AND REINSTALLED the dotnettools "C# for Visual Studio Code (powered by OmniSharp)" extension. I went to the online store and from the right column under Resources I downloaded the ms-dotnettools.csharp-1.25.2#win32-x64.vsix to make sure I get the right one. And restarted vscode.
I tried this setting:
Omnisharp: Dotnet Path
Specified the path to a dotnet installation to use when "useModernNet" is set to true, instead of the default system one. This only influences the dotnet installation to use for hosting Omnisharp itself. Example: "/home/username/mycustomdotnetdirectory".
C:/Program Files/dotnet/sdk/6.0.405
And this setting:
Omnisharp: Sdk Path
Specifies the path to a .NET SDK installation to use for project loading instead of the highest version installed. Applies when "useModernNet" is set to true. Example: /home/username/dotnet/sdks/6.0.300.
C:/Program Files/dotnet/sdk/6.0.405
And restarted vscode. And now it says:
[ERROR] Error: Command failed: dotnet.exe --version
'dotnet.exe' is not recognized as an internal or external command,
operable program or batch file.
What? W H A T? lol
What could be wrong? Why isn't it saying where it expected to find it and what to do to locate it? Is there a setting to specify the dotnet.exe path to this C# extension? Does it need always-on internet or something? Does it have DRM? Does it need Edge installed? Wtf?🙂
🙃😭 I just need intellisense; and I've wasted 2h, on only microsoft-owned products.
#Microsoft 0/5 stars
Still don't know why it happens, but here's how to solve it:
The problem was from this: I like to keep all my visual studio code extensions as .vsix files locally in folders so I can remember and get them easily & offline. Sensible enough choice, and I had the correct ms-dotnettools.csharp-1.25.2#win32-x64.vsix for my platform.
But in VSCode, when I install this particular extension via VSIX, even though it succeeds, it can't find .net. If you instead install the extension "normally", ie via vscode's own download, it seems vscode does some extra configuration steps while installing, and probably sets the .net paths correctly or something. Because now it works.
So TL;DR: don't install ms-dotnettools.csharp via vsix, it seems bugged. 😶
Would love to see an answer explaining what's wrong / how to actually do via vsix; but I don't have any more time to debug this rn.

ASP.NET Core 2.1 IIS hosting error 502.5 - Unable to execute dotnet command to determine cause

So I am getting the rather common HTTP Error 502.5 - Process Failure now that I've hosted my project on a server VM running Windows Server 2016. While troubleshooting, I've attempted most of the solutions proposed for the same error:
ASP.NET Core 1.0 on IIS error 502.5.
Nothing else helped, so I'm looking at the answer that received the most upvotes. This mentions running the following command to receive a more meaningful message describing the error:
C:\fullpath\dotnet C:\fullpath\PROJECT.dll
I am honestly not sure how to execute that. What I did was navigate to the published project's containing folder on the server through the cmd, and issue the command like so:
dotnet .\My_Project Integration.dll
But the console prints this in response:
No executable found matching command "dotnet-.\My_Project"
Notice how the DLL is titled 'My_Project Integration.dll, however the word 'Integration' is absent from the console response. I do not know whether the underscore is to blame here, but any help is appreciated getting the command to run.
And of course, if you know of a solution to the actual 502.5, that is welcome as well.
You've likely got this issue: https://github.com/aspnet/Home/issues/1931. The ASP.NET Core IIS Module reads the Web.config to determine what to execute to run the app.
You said running dotnet ".\My_Project Integration.dll" worked successfully and enabling stdout showed the same issue of the path being truncated after the space.
Two options:
Remove the space from your project (this would be the easiest option)
Update your Web.config
If you do #2, your Web.config needs to have something like this for the arguments attribute:
arguments='".\My_Project Integration.dll"'

Rotativa crashes on service fabric node in Azure

I have a project that needs to collect several data and put it in a single pdf, to do so I used Rotativa wrapper. It works fine on my local service fabric cluster and Im able to generate the pdf using ViewAsPdf and then getting the byte array to attach it in an email. The problem comes when I deployed the project in Azure (service fabric cluster) and Im getting this error:
at Rotativa.AspNetCore.WkhtmlDriver.Convert(String wkhtmlPath, String switches, String html, String wkhtmlExe)\r\n at Rotativa.AspNetCore.WkhtmltopdfDriver.ConvertHtml(String wkhtmltopdfPath, String switches, String html)\r\n at Rotativa.AspNetCore.ViewAsPdf.<CallTheDriver>d__19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---
Things that Ive tried:
Installed Visual C++ Redistributable Packages for Visual Studio 2013 and 2015 in x64 and x86 versions in the service fabric node (where the project is being deployed)
Moved the Rotativa folder from wwwroot to the root path of the project and set the path in RotativaConfiguration.Setup() method
Copied msvcp120.dll and msvcr120.dll to the Rotativa folder
Installed wkhtmltopdf.exe in the service fabric node
I installed Rotativa.AspNetCore 1.0.6 nuget package
I use ViewAsPdf to render the razor view and I call BuildFile method to get the byte array
If I ran the wkhtmltopdf.exe in the command line in the service fabric node I get: "The application was unable to start correctly(0xc000007b) Click ok to close the application"
The service fabric node is a Windows machine. The project is built with aspnet core 2.0
Any help will be appreciated. Thanks!
I assume is a missing dependency issue.
Based on the scenario and message you provided The application was unable to start correctly(0xc000007b) there are other related problems:
The application was unable to start correctly (0xc000007b) and Error : the application was unable to start correctly
The other issue might be lack of permissions to run or access specific dependencies.
I would suggest you try:
running as administrator first via command line.
Check firewall or network\website permissions
Use dependency walker and check the dependencies it loads\fail and verify if they are installed on the server.
As a workaround you could create a container to run this. It would save you the trouble of going into the nodes to install stuff, which limits your scale out & fail-over options.
There are some people who got it working.

How to limit webdeploy connection number, ERROR_EXCEEDED_MAX_SITE_CONNECTIONS

I have a solution that has 10-20 web projects, and I am trying to use msbuild webdeploy to deploy them.
msbuild "mysolution.sln" /p:DeployOnBuild=true /p:PublishProfile="Debug"
However, I got this error in the middle of deploy:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4295,5): msdeploy error ERROR_EXCEEDED_MAX_SITE_CONNECTIONS: Web deployment task failed. (The maximum number of connections for this site has been exceeded.
In the log, before this error, a few projects were being deployed and files were updated. It seems that msbuild is trying to deploy as many as projects at the same time as possible, and exceeded the max connection number.
So how can I limit the connection number, is there an option in the publish profile?
Update - workaround
I have got a workaround from viet.hoang in Sitecore slack channel. It basically increases the max connection number on the server and/or retry attemps in the publish profile.
Increase max connection number: go to the target server and add adding the following to the registry: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3] "MaxSiteConnections"=dword:00000010. Then restart Web Management Service.
Increase retry attempts: in the publish profile there is an option "RetryAttemptsForDeployment", add it and set the value to 20.
The workaround works, no more error in the deployment. But I am still hopeful that someone will be able to provide some insights and a proper solution that doesn't require registry modification and can throw other types of errors quickly without retry 20 times.
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
I had the same problem when host by web deploy from visual studio 2017. after researching through online i had come across a solution . please follow the link: https://youtu.be/nOonbx9FgJQ

Exception thrown using VS publish on 1 developers machine

When deploying 1 application through Visual Studio 2017 & 2015 one of our devs is getting the exception below raised in the servers event logs.
No other developer gets this exception, and it seems to happen for all apps that developer tries to deploy.
Here's what the log says about it on the server ...
The description for Event ID 1 from source Web Deploy cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
User: S0000878\WROW
Client IP: 10.100.177.100:80
Content-Type: application/msdeploy
Version: 9.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 9.0.1972.0
MSDeploy.Method: Sync
MSDeploy.RequestId: 94589097-54ba-4753-a37b-32571bfe6b8f
MSDeploy.RequestCulture: en-GB
MSDeploy.RequestUICulture: en-GB
ServerVersion: 9.0.1962.0
Skip: objectName="^configProtectedData$"
Provider: auto, Path:
A tracing deployment agent exception occurred that was propagated to the client. Request ID '94589097-54ba-4753-a37b-32571bfe6b8f'. Request Timestamp: '16/05/2017 10:26:59'. Error Details:
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt16()
at Microsoft.Web.Deployment.PackageDeserializer.GetNextEntryType()
at Microsoft.Web.Deployment.SerializationProvider..ctor(DeploymentBaseContext baseContext, PackageDeserializer deserializer)
at Microsoft.Web.Deployment.PackageDeserializer.GetSerializationProvider()
at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId, String user, String siteName)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)
I'm at a loss because the deployment process works from all other dev machines and from our build boxes, and yet it's only the server that complains.
What should I be looking for on the developers machine that might help indicate the real problem here?
It seems that the problem was caused by proxy settings on the developers machine.
this sort of problem can be caused by tools like Fiddler (often used by developers to debug API calls to web services).
The developer seems to have fixed it by repairing VS in this instance suggesting that there was also an issue with the VS install.
In my case, the issue was caused by a security software in our environment. However, while doing research about this issue, I noticed that these are also required for Web Deploy to work:
Management Services should be installed (Add Role and Features > Web
Server)
Web Management Service sand Web Deploy Agent Service hould be
running
Make sure Fiddler or any other similar software is not
running while publishing
Make sure TCP port 8172 is open in the
server
Source: Web Deploy experienced a connection problem (ERROR_CONNECTION_TERMINATED)

Categories