The `dotnet build` command from .NET SDK 10 fails with exit code -1 when run by AppVeyor service

splatteredbits's Avatar

splatteredbits

03 Dec, 2025 12:58 AM

We're unable to run builds on servers in Windows PowerShell. We have a dotnet build command that on .NET SDK 10 under Windows PowerShell, exits with a -1 exit code, with no console output and no log output.

Build history is here: https://ci.appveyor.com/project/WebMD-Health-Services/whiskey/history

Build script we're running: https://github.com/webmd-health-services/Whiskey/blob/master/build.ps1 . The failing dotnet build command is on line 188. For the repo and it should repro.

Sometimes, if I repeatedly run the dotnet build command, it will sometimes eventually work, but not always (I've only ever tried for at most five minutes).

If I pin to .NET 8.0 instead of LTS (which currently resolves to .NET 10.0, the problem goes away.

If I log into the build server interactively, the dotnet build command and the build.ps1 script always work. It is only an issue when running non-interactively by the AppVeyor service.

  1. Support Staff 1 Posted by Owen McDonnell on 03 Dec, 2025 06:55 PM

    Owen McDonnell's Avatar

    Are you able to build on a newer image, Visual Studio 2019 or Visual Studio 2022?

  2. 2 Posted by splatteredbits on 03 Dec, 2025 07:07 PM

    splatteredbits's Avatar

    It fails on the Visual Studio 2019 and Visual Studio 2022 images as well: https://ci.appveyor.com/project/WebMD-Health-Services/whiskey/build...

  3. Support Staff 3 Posted by Owen McDonnell on 03 Dec, 2025 10:16 PM

    Owen McDonnell's Avatar

    Can you change Write-Verbose "dotnet build $($params -join ' ')" to Write-Host "dotnet build $($params -join ' ')".
    It would help to see the actual complete build command that is being called is.

  4. 4 Posted by splatteredbits on 03 Dec, 2025 10:52 PM

    splatteredbits's Avatar

    Done. I turned on verbose output for that message. I also added a message that shows the exit code before the command and after.

  5. Support Staff 5 Posted by Owen McDonnell on 03 Dec, 2025 11:15 PM

    Owen McDonnell's Avatar

    Thanks.
    Sorry, i didn't realize your build log was not being uploaded on failing build.
    Can you follow docs here to push C:\projects\whiskey\.output\msbuild.whiskey.log to artifacts on build failure.

  6. 6 Posted by splatteredbits on 03 Dec, 2025 11:26 PM

    splatteredbits's Avatar

    Done. Unfortunately, it doesn't even generate a log file. I've updated appveyor.yml to publish all the *.log files, but you'll see they aren't there. I added verbose messages to the build script that shows the .output directory is empty. I even increased the log level to diag for the log file.

  7. Support Staff 7 Posted by Owen McDonnell on 04 Dec, 2025 07:29 PM

    Owen McDonnell's Avatar

    I've forked your repo and am trying to assess the issue. I'm trying to determine if it's a problem with the build machine image or with newer dotnet sdk and/or powershell.

    What was the last successful build with dotnet 10? Was it on Visual Studio 2017 image? That image hasn't changed for quite some time. Can you successfully Re-Build Commit of last successful build?

    Also, when you say you can RDP to the worker and run the build.ps1 script, are you doing that in powershell core?

  8. 8 Posted by splatteredbits on 04 Dec, 2025 07:39 PM

    splatteredbits's Avatar

    I don't think we've ever had a successful build with .NET 10. I'll have to review logs.

    I'm running build.ps1 in Windows PowerShell, same as the build should be running.

  9. 9 Posted by splatteredbits on 04 Dec, 2025 07:45 PM

    splatteredbits's Avatar

    Here's our last successful build running, 15 Oct 2025, on all the images we want, which included Visual Studio 2017: https://ci.appveyor.com/project/WebMD-Health-Services/whiskey/build... . If I rebuild that commit it will fail, because the build script pins to the .NET LTS, not a specific version. It will download .NET 10 SDK.

    The next build ran a month later on 17 Nov 2025. It downloaded and used .NET 10 SDK. and failed. https://ci.appveyor.com/project/WebMD-Health-Services/whiskey/build...

  10. 10 Posted by splatteredbits on 04 Dec, 2025 07:47 PM

    splatteredbits's Avatar

    I am also not sure if this is a problem with .NET 10 SDK or your service/VMs. I reported https://github.com/dotnet/sdk/issues/51982 to the .NET SDK GitHub project, but have yet to receive any response.

  11. Support Staff 11 Posted by Owen McDonnell on 04 Dec, 2025 09:33 PM

    Owen McDonnell's Avatar

    Can you try changing your build script to pwsh: instead of ps: and let us know if there is any difference in terms of build output?

  12. 12 Posted by splatteredbits on 04 Dec, 2025 09:38 PM

    splatteredbits's Avatar

    The problem does not happen when run under PowerShell/pwsh: https://ci.appveyor.com/project/WebMD-Health-Services/whiskey/build... .

  13. Support Staff 13 Posted by Owen McDonnell on 05 Dec, 2025 01:43 AM

    Owen McDonnell's Avatar

    Either use powershell core, or remove $ErrorActionPreference = 'Stop' from your build script.
    Seems that new dotnet cli is outputting something to stderr.

    I guess AppVeyor powershell session differs from a live one, but regardless, I don't think this is something that can be resolved by our updating build images.

  14. 14 Posted by splatteredbits on 05 Dec, 2025 01:45 AM

    splatteredbits's Avatar

    We can't use PowerShell Core since we need to test that our PowerShell module runs on Windows PowerShell.

    If we remove $ErrorActionPreference = 'Stop' our build will still fail because dotnet build won't compile our project.

  15. Support Staff 15 Posted by Owen McDonnell on 05 Dec, 2025 07:20 PM

    Owen McDonnell's Avatar

    In that case you could use this function to call the dotnet command.
    Put that function in a ps1 file in your repo and then dot source it at the start of your appveyor.yml build script section. Then call Start-ProcessWithOutput "dotnet build $params".
    There's also a flag for ingoring exit codes.

  16. 16 Posted by splatteredbits on 17 Dec, 2025 07:55 PM

    splatteredbits's Avatar

    Instead of building our package in each build job, we're instead going to have a dedicated job that builds our package, then verify that package in other jobs. We can run that build job on a platform and PowerShell version that works using the latest .NET SDK.

  17. 17 Posted by splatteredbits on 25 Jun, 2026 12:31 AM

    splatteredbits's Avatar

    Solved.

    Root of the problem is that .NET 10 now outputs its first-run, "we're collecting telemetry!" message to STDERR (previous versions of .NET output to STDOUT) and our PowerShell script has $ErrorActionPreference = 'Stop'. PowerShell 5.1 sees the message written to STDERR and I think it immediately terminates the dotnet process. Because the first line is an empty string, PowerShell 5.1, which usually outputs the STDERR in its error message, outputs nothing.

    Solution is to set DOTNET_NOLOGO to true on all build servers to prevent the telemetry message from showing.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? 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

18 Jul, 2026 09:25 AM
16 Jul, 2026 06:29 AM
09 Jul, 2026 04:35 PM
07 Jul, 2026 07:22 PM
30 Jun, 2026 08:51 PM