Build Hanging Even After Script Exits

Muhammad Rehan Saeed's Avatar

Muhammad Rehan Saeed

06 Jun, 2018 09:31 AM

My build script completes and returns an exit code of 0 but the AppVeyor build hangs and does not complete itself. Eventually timing out after an hour. What could be causing this?

  1. Support Staff 1 Posted by Ilya Finkelshte... on 06 Jun, 2018 04:33 PM

    Ilya Finkelshteyn's Avatar

    Hi Muhammad,

    First let us try to isolate if it is related to the code change or recent build worker image update. For that do the following two simple experiments:

    • Open last good build and press RE-BUILD COMMIT

    • In the current version of YAML replace image: Visual Studio 2017 with image: Previous Visual Studio 2017.

    Let us know what you found and we will determine the next steps.


  2. 2 Posted by Muhammad Rehan ... on 07 Jun, 2018 10:39 AM

    Muhammad Rehan Saeed's Avatar

    Last good build still succeeded.
    I can't use the previous VS 2017 because I am using .NET Core 2.1.

  3. Support Staff 3 Posted by Ilya Finkelshte... on 08 Jun, 2018 07:52 AM

    Ilya Finkelshteyn's Avatar

    Just FYI -- we forked your project and trying to root cause. Will update soon.

  4. 4 Posted by Muhammad Rehan ... on 08 Jun, 2018 07:59 AM

    Muhammad Rehan Saeed's Avatar

    Excellent thanks!

  5. Support Staff 5 Posted by Owen McDonnell on 09 Jun, 2018 12:46 AM

    Owen McDonnell's Avatar

    Do you know if the cake bootstrapper pacakges.config you use (which looks emphatically deprecated by the way) updates apace with cake releases? If so, it seems that your builds started breaking around the new 0.28.0 release.

    It's not immediately apparent to me how you could pin an earlier version of cake to test. Any ideas?

  6. 6 Posted by Muhammad Rehan ... on 09 Jun, 2018 06:13 AM

    Muhammad Rehan Saeed's Avatar
  7. Support Staff 7 Posted by Owen McDonnell on 09 Jun, 2018 06:12 PM

    Owen McDonnell's Avatar

    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.

    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.

  8. 8 Posted by Muhammad Rehan ... on 12 Jun, 2018 08:17 AM

    Muhammad Rehan Saeed's Avatar

    When I run .\build.ps1 locally, the cake script runs and exits perfectly. I only get the issue on AppVeyor for some reason.

    I've also raise the following Cake issue:

  9. Support Staff 9 Posted by Ilya Finkelshte... on 12 Jun, 2018 08:51 AM

    Ilya Finkelshteyn's Avatar

    Yesterday we closed somehow similar issue with setting -maxthreads 1 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.

  10. 10 Posted by Muhammad Rehan ... on 12 Jun, 2018 09:04 AM

    Muhammad Rehan Saeed's Avatar

    I set max threads to 1 in the build below but it's still hanging:

  11. 11 Posted by Muhammad Rehan ... on 14 Jun, 2018 03:39 PM

    Muhammad Rehan Saeed's Avatar

    I managed to work around this issue by adding the following to my cake script:

    Teardown(context =>
        // Appveyor is failing to exit the cake script.
        if (AppVeyor.IsRunningOnAppVeyor)
            foreach (var process in Process.GetProcessesByName("dotnet"))

    How does AppVeyor decide to end the build?

  12. Support Staff 12 Posted by Ilya Finkelshte... on 15 Jun, 2018 04:52 PM

    Ilya Finkelshteyn's Avatar

    If any of steps in pipeline return exit code other than 0, build fails. Otherwise succeed.

    AppVeyor has custom implementation of PowerShell's PSHost in which commands like Cake script runs. What happened here is those handing processes do not let it exit command execution.

    Did you see Martin's investigation?

  13. 13 Posted by Muhammad Rehan ... on 16 Jun, 2018 12:39 PM

    Muhammad Rehan Saeed's Avatar

    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.

  14. 14 Posted by gep13 on 16 Jun, 2018 08:06 PM

    gep13's Avatar


    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.


  15. 15 Posted by Muhammad Rehan ... on 18 Jun, 2018 08:13 AM

    Muhammad Rehan Saeed's Avatar

    Looks like we have to wait for the dotnet CLI to fix this [bug](, in the mean time, my workaround is working for me.

  16. Owen McDonnell closed this discussion on 27 Aug, 2018 06:35 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 09:10 AM


21 Aug, 2019 05:56 AM
21 Aug, 2019 03:08 AM
20 Aug, 2019 11:33 PM
20 Aug, 2019 08:07 PM
20 Aug, 2019 05:50 PM
20 Aug, 2019 12:35 PM