TeamCity ".Net Process Runner" hangs - c#-4.0

We have started migrating our one of several projects to team city as part of CI. Below is how we have setup teamcity build. We are trying to deploy WebSite.
1) Build Step 1 (Package installation)
Using "command line " runner type install required package.
2) Build Step 2 (Build)
Using Runner type "Visual Studio (sln)" (Visual Studio 2010) build website.
3) Build Step 3 (Deploy Web Site)
Using ".Net Process Runner", deployer.exe (x86 built with .Net Framework 4) deploy site.
Deployer.exe reads config file. Config file contains "BuildId", "Environment" and "Servers" where we want build to be pushed.
<buildType id="bt52">
<env name="Debug">
<server path="SERVER1" />
</env>
<env name="QA">
<server path="SERVER2" />
<server path="SERVER3" />
</env>
<env name="UAT">
<server path="SERVER4" />
<server path="SERVER5" />
</env>
</buildType>
Deployer.exe is called with required parameters as below. Which reads config and deploys site to Server2 and Server3.
Deployer.exe "bt52" "QA" "siteQA" "E:\BuildAgent\work\2483052e33e5e1e8\src\diy\" msdeploy.exe
Problem area is step #3.
When we run deployer.exe using .Net process runner as part of team city we see its hanging and not responsind sometime even for 45 minutes. When we try to execute same deployer.exe from build server using command line script executes within couple of seconds.
E:\TeamCity_custom_applications\deployer>Deployer.exe farm1-1 QA siteQA E:\BuildAgent\work\2483052e33e5e1e8\src\diy\ msdeploy.exe
Info
: Processing batch run ... Info : Processing command ...msdeploy.exe
-verb:sync -source:contentPath="E:\BuildAgent\work\2483052e33e5e1e8\src\diy\" -dest:contentPath="siteQA",wmsvc="SERVER2",userName="*****",password="******",authType="Basic"-skip:objectName=filePath,absolutePath=web.config -skip:objectName=dirPath,absolutePath="bin" -enableRule:DoNotDeleteRule -allowUntrusted Info : output >>Total changes: 0 (0 added, 0 deleted, 0 updated, 0 parameters changed, 0
bytes copied) Info : error >>(none) Info : ExitCode >> 0 Info :
Processing command ...msdeploy.exe -verb:sync
-source:contentPath="E:\BuildAgent\work\2483052e33e5e1e8\src\diy\" -dest:contentPath="siteQA",wmsvc="SERVER3",userName="******",password="******",authType="Basic"
-skip:objectName=filePath,absolutePath=web.config -skip:objectName=dirPath,absolutePath="bin" -enableRule:DoNotDeleteRule -allowUntrusted Info : output >>Total changes: 0 (0 added, 0 deleted, 0 updated, 0 parameters ch anged, 0
bytes copied) Info : error >>(none) Info : ExitCode >> 0
Info: Deploy Script Complete.
One more thing we observed is running deployer.exe through teamcity I see that site content gets copied but only for 1 server and teamcity build status stays in "Running" mode. I am wondering if someone can please put little bit of insight on how can I look into this issue.
Update 1:
Thanks for your time looking into it !! What we ended up doing is, Instead of running command "msdeploy.exe" from "cmd.exe" we added "msdeploy.exe" location as Environment variable and executed "msdeploy.exe" in loop for # of servers. This has resolved issue of hanging. Now I am just curious to know why would it behave in such manner where if you execute "msdeploy.exe" from "cmd.exe" it would hang while running directly "msdeploy.exe" it would execute successfully. Any insight into same would be greatly appreciated.
Update 2:
I have added image which explains behavior using process explorer. If we kill msdeploy.exe from process explorer than for next all deployments to that server will not have the issue of build hanging. Please see below image

To be honest, it sounds like you're running into issues with redirecting input/output streams. TeamCity is running your application in a totally headless environment and then you, in turn, are attempting to redirect and parse the output of msdeploy.exe
If that's the case, I'd recommend looking into using the MSDeploy API instead of msdeploy.exe. The latter is just a command line wrapper for the former, so all the functionality is available to you. There's a sample deployment application available on the IIS blog if you need help getting started.

It seems you have NUnit build step configured in TeamCity and invoke cmd.exe from your test. This looks like an issue with the test code then. Most probably it will reproduce without TeamCity if you run the test in question with NUnit directly.
As Richard noted, most probably the issue root cause is related to stdin/stdout processing.
If you want to fix it in your code, you can try to experiment by explicitly closing stdin or the other way around, try writing something into it, etc.

Work around we did is, we observed msdeploy doesn't take more than 3-5 seconds to execute and deploy (Even for our biggest project which is almost 300mb website). So we set timeout of 20 seconds. So far since last 1 weeks we have not seen any issue with it and hopefully it will not cause more trouble but still we are not sure why such behavior.

Related

GenerateEFSQLScripts fails when trying to publish to IIS using Web Deploy from TeamCity

Running into a total dead-end here.
I've created a Publish Profile for a .net6 application that we want to publish to IIS with Web Deploy. In the Entity Framework Migration section, the option to "Apply this migration on publish" is selected.
When manually clicking publish, everything works. However, we want to automate this in TeamCity using the .NET build runner. The publish step fails at:
Generating Entity Framework SQL Scripts...
Executing command: dotnet ef migrations script --no-build --idempotent --configuration Release --output "C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api\obj\Release\net6.0\PubTmp\EFSQLScripts\MySolution.Data.MyContext.sql" --context MySolution.Data.MyContext
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(221,5): error : Entity Framework SQL Script generation failed
Internal error message details: BuildMessage1 0 Text DefaultMessage ERROR 400682522803500 tags:'tc:parseServiceMessagesInside'
Error message is logged
Build FAILED.
I cannot find any specific error messages anywhere in any log. Looking in the Microsoft.NET.Sdk.Publish.TransformFiles.targets file shows that it's failing on GenerateEFSQLScripts - an MSBuild command that executes dotnet ef under the covers.
I thought this might be a case of dotnet ef not being installed on the build agent. But when I manually run the command myself from C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api, it succeeds, and the SQL scripts are successfully created.
I also thought it might just be a case of the command being run in the wrong directory (i.e. in the root MySolution folder rather than the MySolution.Api folder), but explicitly setting the working directly fails at the same point, with the same error.
Has anyone seen this before? Or could point me to where an actual error might be located?

CruiseControl.net Project Fails with no errors, how to identify error?

Had cruise control.net (v1.8.5.0) up and running for about 6 months on 4 projects, no issues.
In the past week or so, one project reports a failure... even though it compiles correctly and no unit test errors are reported as they were previously on failures. None of similiar reports on SO or elsewhere describe or correct this problem.
Here is dashboard status:
BluePrint Failure Breakers : support2 Failing Tasks : NUnitTask
In the build report log where it would normally show which tests failed, it shows no failures just the unit startup message:
ProcessModel: Default DomainUsage: Single Execution
Runtime: net-3.5
Normally here for an nunit error the erroring test #s and names that failed and the nunit assert failure message. In a passing situation it would display xml for each test.
Can someone point me somewhere else what might be causing this or where else I might look to find out why?
When I run nunit manually on the same tests the cruise control service has checked out the build server, everything works fine.
I've tried restarting both the cruise control service and IIS, same result.
When I look in the ccnet.log file on the server, it doesn't report anything more specific than whats already in the build log above:
Done Building Project
"C:\Users\j\Documents\CIWork\BluePrint\BluePrint.sln" (Build
target(s)).
Build succeeded.
0 Error(s)
Time Elapsed 00:00:13.99
2017-01-20 18:50:36,869 [BluePrint:DEBUG] Running unit tests:
C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe
/xml=C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml
/nologo
C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe
2017-01-20 18:50:36,869 [BluePrint:DEBUG] Starting process [C:\Program
Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] in working directory
[C:\Program Files
(x86)\CruiseControl.NET\server\BluePrint\WorkingDirectory] with
arguments
[/xml=C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml
/nologo
C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe]
2017-01-20 18:50:36,953 [BluePrint:DEBUG] Not setting PriorityClass on
[C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] to default
Normal 2017-01-20 18:50:37,686 [20:DEBUG] [BluePrint C:\Program Files
(x86)\NUnit 2.6.3\bin\nunit-console.exe] ProcessModel: Default
DomainUsage: Single 2017-01-20 18:50:37,686 [20:DEBUG] [BluePrint
C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] Execution
Runtime: net-3.5
My configuration has not changed in 6months, here's the relevant task from ccnet.config:
<nunit>
<path>C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe</path>
<outputfile>C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml</outputfile>
<assemblies>
<assembly>C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe</assembly>
</assemblies>
</nunit>
As I was posting this I recalled that one of these tests downloaded a fair amount of data from internet and cached it. Running it from the console worked, but running it from system account as service must've been slower to exceeded default cruisecontrol timeout.
Weird that no timeout error was in the log. However copying the cached files from the admin account to systemprofile account fixed it. Will also see if the nunit test can be modified to automatically time itself out.

Azure Websites Git Deployment dropping "/" in SCM_BUILD_ARGS

Description
We are in a current project based on MVC4/Umbraco using Azure Websites to host it.
We are using SCM_BUILD_ARGS to change between different build setups depending on which site in Azure we deploy to (Test and Prod).
This is done by defining an app setting in the UI:
SCM_BUILD_ARGS = /p:Environment=Test
Earlier we used Bitbucket Integration to deploy and here this setting worked like a champ.
We have now switched to using Git Deployment, pushing the changes from our build server when tests have passed.
But when we do this, we get a lovely error.
"MSB1008: Only one project can be specified."
Trying to redeploy the same failed deployment from the UI on Azure works though.
After some trial and error I ended going into the deploy.cmd and outputting the %SCM_BUILD_ARGS% value in the script.
It looks like the / gets dropped from SCM_BUILD_ARGS but only when using Git deploy, not Bitbucket Integration or redeploy from UI.
Workaround
As workaround I have for now added a / to the deploy.cmd script in front of the %SCM_BUILD_ARGS%, but this of course breaks redeploy, since we then have //p:Environment=Test in the MSBuild command when the value of %SCM_BUILD_ARGS% has been inserted.
:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
:: Added / to SCM_BUILD_ARGS
%MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....] /%SCM_BUILD_ARGS%
) ELSE (
%MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....] /%SCM_BUILD_ARGS%
)
Question
Anyone know of a better solution for this problem or is it possibly a bug in Kudu?
We would love to have both deploy from Git and Redeploy working.
Could you try changing from "/" to "-"? For instance, AppSettings from /p:Environment=Test to -p:Environment=Test, see if it helps.
-p:Environment=Test did not work for me, the setting which worked for me at the time of this writing (September 2015) was
-p:Configuration=Test
There is clearly a Kudu bug in there, and you should open an issue on https://github.com/projectkudu/kudu. But for now, I can give you a workaround.
Instead of using an App Setting, include a .deployment file at the root of your repo, containing:
[config]
SCM_BUILD_ARGS = /p:Environment=Test
I think this will work in all cases. I suspect the bug has to do with bash messing up the environment in post receive hook scenarios, which only apply to direct git push but not to Bitbucket and Redeploy scenarios.
UPDATE: In fact, it's easy to see such weird bash behavior. Try this:
Open cmd.exe
Run: set foo=/abc to set a variable
Run bash
From bash, run cmd to launch a new cmd on top of bash (so cmd -> bash -> cmd)
Run set foo to get the value of foo
Result:
FOO=C:/Program Files (x86)/git/abc
So the value gets completely messed up. The key also gets upper cases, though that's mostly harmless. Strange stuff...

Can't get azure web role to run locally using the emulator

I have a web role that I'm trying to run locally using the emulator. I have it working on another computer, but I cannot get it working on a different one, and have gone as far as to reformat it and start from scratch.
When I launch the site from Visual Studio, Chrome shows the following message:
This webpage is not available
The connection to 127.0.0.1 was interrupted.
There is also an error code listed at the bottom:
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
One interesting thing from the build output are these lines:
Starting process 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\v1.8\Debugger\WindowsAzureDebugger.exe' with arguments '"C:\Program Files\IIS Express\iisexpress.exe" /trace:error /config:"C:\Users\brian\AppData\Local\dftmp\Resources\159c7254-b7d0-4076-a4fd-820b00feca5f\temp\temp\RoleTemp\applicationHost.config" /site:"deployment18(27).AzureApp.MyApp.Web_IN_0_Web"'...
Process 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\v1.8\Debugger\WindowsAzureDebugger.exe' exited with exit code 0.
If I run C:\Program Files\IIS Express\iisexpress.exe" /trace:error /config:"C:\Users\brian\AppData\Local\dftmp\Resources\159c7254-b7d0-4076-a4fd-820b00feca5f\temp\temp\RoleTemp\applicationHost.config" /site:"deployment18(27).AzureApp.MyApp.Web_IN_0_Web" from the command line, I get the following message:
The system cannot find the file specified.
Unable to start IIS Express in background.
I have no idea what file it cannot find, but I've verified that the config file I'm passing does in fact exist. Anyone have a clue what's going on here??
While I can not tell you what could be the actual root cause of your problem I can suggest a few ways to troubleshoot it:
Try changing IIS Express to Full IIS and see if it changes the behavior. You can do it by going to your Windows Azure Application project properties and look at "Web" option.
Try running application without debugging it
Launch CSrun at command prompt with /launchDebugger parameter of the /run option to verify that debugger does run without any issue
Try using IE as default browser
Clean your dftemp folder completely for any residual configuration and then launch Azure Emulator separately to verify there are no issues
Procmon "http://technet.microsoft.com/en-us/sysinternals/bb896645" may help you find the file that is missing...
Hopefully someone stumbles upon this answer with similar symptoms. When removing in role caching the <dataCacheClients> section was removed from . Somehow there was a left over <dataCacheClients> section left in the web.config. Everything and compiled and deployed to the emulator successfully. However, the role would fail to start since applicationHost.config was missing.
The fix was simply remove the unnecessary <dataCacheClients> section from the web.config file.

CruiseControl.net and cronTrigger

So, I'm having this odd issue with my CruiseControl.net project. I have a ccnet.config file that goes and pulls from my bitbucket repo, runs a basic build, then runs some unit tests, and then finally copies the tested files out to the webroot. Seems pretty basic, even for being my first time using CC.Net.
I, of course, would like this to run when I do commits. Failing writing some sort of web page that bitbucket can invoke through it's services framework, I settled for having CC run a scheduled build, and only run the full build if there's source control changes.
After some googling, I found out that in 1.6, it has a cronTrigger. Excactly what I need. So, I add the following chunk to my config:
<cronTrigger>
<cronExpression>*/5 * * * *</cronExpression>
</cronTrigger>
Then it triggers fine, but then I get a loop of this in the console:
[HMS:INFO] Calling hg log -r tip --template {rev} --noninteractive
[HMS:DEBUG] Starting process [C:\Program Files (x86)\TortoiseHg\hg.exe] in working directory [C:\build\hms\src] with arguments [log -r tip --template {rev} --noninteractive]
[HMS:DEBUG] Not setting PriorityClass on [C:\Program Files (x86)\TortoiseHg\hg.exe] to default Normal
[8:DEBUG] [HMS C:\Program Files (x86)\TortoiseHg\hg.exe] standard-error stream closed -- null received in event
[7:DEBUG] [HMS C:\Program Files (x86)\TortoiseHg\hg.exe] 60
[7:DEBUG] [HMS C:\Program Files (x86)\TortoiseHg\hg.exe] standard-output streamclosed -- null received in event
[3:DEBUG] [HMS C:\Program Files (x86)\TortoiseHg\hg.exe] process exited event received
[HMS:INFO] No modifications detected.
This loop continues until I go in and remove the cronTrigger block. I don't really want this thing busy-waiting on my server for a change, and I'm sure BitBucket doesn't smile upon several requests per second.
So, in short, how do I stop this thing from molesting bitbucket? Stop using CC.Net? Resign myself to hitting the "Build" button?
Also: my ccnet.config file for reference: http://pastebin.com/6jSPxVTk
I said screw it, I moved to Hudson instead. A bit heavier on my server, but it supports a URL to post to, so I can drop that into BitBucket's "Services" option, so no polling.
I also get a free Jabber bot, and Chuck Norris.

Resources