tag:help.appveyor.com,2012-11-13:/discussions/problems/14580-build-hanging-even-after-script-exitsAppVeyor: Discussion 2018-10-19T08:18:48Ztag:help.appveyor.com,2012-11-13:Comment/454249492018-06-06T16:33:39Z2018-06-06T16:33:39ZBuild Hanging Even After Script Exits<div><p>Hi Muhammad,</p>
<p>First let us try to isolate if it is related to the code change or <a href="https://www.appveyor.com/updates/2018/06/03/">recent build worker image</a> update. For that do the following two simple experiments:</p>
<ul>
<li>
<p>Open <a href="https://ci.appveyor.com/project/RehanSaeed/templates/build/387">last good build</a> and press <code>RE-BUILD COMMIT</code></p>
</li>
<li>
<p>In the current version of YAML replace <code>image: Visual Studio 2017</code> with <code>image: Previous Visual Studio 2017</code>.</p>
</li>
</ul>
<p>Let us know what you found and we will determine the next steps.</p>
<p>Ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/454249492018-06-07T10:39:02Z2018-06-07T10:39:03ZBuild Hanging Even After Script Exits<div><p>Last good build still succeeded.<br>
I can't use the previous VS 2017 because I am using .NET Core 2.1.</p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-08T07:52:51Z2018-06-08T07:52:51ZBuild Hanging Even After Script Exits<div><p>Just FYI -- we forked your project and trying to root cause. Will update soon.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/454249492018-06-08T07:59:59Z2018-06-08T08:00:00ZBuild Hanging Even After Script Exits<div><p>Excellent thanks!</p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-09T00:46:00Z2018-06-09T00:46:00ZBuild Hanging Even After Script Exits<div><p>Do you know if the cake bootstrapper pacakges.config you use (which looks <a href="https://github.com/cake-build/bootstrapper">emphatically deprecated</a> by the way) updates apace with cake releases? If so, it seems that your builds started breaking around the new 0.28.0 release.</p>
<p>It's not immediately apparent to me how you could pin an earlier version of cake to test. Any ideas?</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/454249492018-06-09T06:13:41Z2018-06-09T06:13:43ZBuild Hanging Even After Script Exits<div><p>You can pin a version of cake:</p>
<p><a href="https://cakebuild.net/docs/tutorials/pinning-cake-version">https://cakebuild.net/docs/tutorials/pinning-cake-version</a></p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-09T18:12:09Z2018-06-09T18:12:09ZBuild Hanging Even After Script Exits<div><p>I've tried to locally rebuild several of your previous commits and various combinations and from them it seems that once the target framework changed to netcoreapp2.1 and the sdk to 2.1.300, there is some problem with cake killing .net core processes.</p>
<p>To reproduce choose any commit after said .net core upgrade and run the build script. Open task manager or process explorer and see .net core processes. They remain when the script returns. If you run it again, more are created. I believe this is irrespective of what version of cake is being used.</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/454249492018-06-12T08:17:03Z2018-06-12T08:17:04ZBuild Hanging Even After Script Exits<div><p>When I run .\build.ps1 locally, the cake script runs and exits perfectly. I only get the issue on AppVeyor for some reason.</p>
<p>I've also raise the following Cake issue:</p>
<p><a href="https://github.com/cake-build/cake/issues/2189">https://github.com/cake-build/cake/issues/2189</a></p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-12T08:51:19Z2018-06-12T08:51:19ZBuild Hanging Even After Script Exits<div><p>Yesterday we closed <a href="https://github.com/appveyor/ci/issues/2393">somehow similar issue</a> with setting <code>-maxthreads 1</code> for xunit console. I understand that this is different situation, because Cake and .NET Core tests are involved here, but I still have feeling that this can be issue related to multi threading. Sorry for vague comment, we will continue investigating. Any ideas are highly appreciated.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/454249492018-06-12T09:04:19Z2018-06-12T09:04:20ZBuild Hanging Even After Script Exits<div><p>I set max threads to 1 in the build below but it's still hanging:</p>
<p><a href="https://ci.appveyor.com/project/RehanSaeed/templates/build/436">https://ci.appveyor.com/project/RehanSaeed/templates/build/436</a></p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-14T15:39:16Z2018-06-14T15:39:17ZBuild Hanging Even After Script Exits<div><p>I managed to work around this issue by adding the following to my cake script:</p>
<pre>
<code>Teardown(context =>
{
// Appveyor is failing to exit the cake script.
if (AppVeyor.IsRunningOnAppVeyor)
{
foreach (var process in Process.GetProcessesByName("dotnet"))
{
process.Kill();
}
}
});</code>
</pre>
<p>How does AppVeyor decide to end the build?</p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-15T16:52:48Z2018-06-15T16:52:48ZBuild Hanging Even After Script Exits<div><p>If any of steps in <a href="https://www.appveyor.com/docs/build-configuration/#build-pipeline">pipeline</a> return exit code other than 0, build fails. Otherwise succeed.</p>
<p>AppVeyor has custom implementation of PowerShell's <code>PSHost</code> in which commands like Cake script runs. What happened here is those handing processes do not let it exit command execution.</p>
<p>Did you see <a href="https://github.com/cake-build/cake/issues/2189#issuecomment-397427077">Martin's investigation</a>?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/454249492018-06-16T12:39:09Z2018-06-16T12:39:12ZBuild Hanging Even After Script Exits<div><p>Yes, it seems my code is not at fault. Hurrah! I'll wait for Cake to put in a fix and use the workaround in the mean time. Thanks for your efforts.</p></div>Muhammad Rehan Saeedtag:help.appveyor.com,2012-11-13:Comment/454249492018-06-16T20:06:00Z2018-06-16T20:06:00ZBuild Hanging Even After Script Exits<div><p>Muhammad,</p>
<p>Can you confirm what sort of fix you are looking for in Cake here? Surely this would be a fix required in the dotnet cli? I don't see what we, as the Cake Team, could do here.</p>
<p>Gary</p></div>gep13tag:help.appveyor.com,2012-11-13:Comment/454249492018-06-18T08:13:18Z2018-06-18T08:13:20ZBuild Hanging Even After Script Exits<div><p>Looks like we have to wait for the dotnet CLI to fix this <a href="https://github.com/dotnet/roslyn/issues/27566">bug</a>, in the mean time, my workaround is working for me.</p></div>Muhammad Rehan Saeed