dotnet / dotnet/sdk

The `dotnet build` command returns exit code -1 and shows no output when first run in Windows PowerShell 5.1 and $ErrorActionPreference is Stop

Open
#51,982 1 comment 0 reactions 1 assignee Claimed by @baronfel View on GitHub
Area-CLI untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

Beginning with the .NET 10 SDK, the `dotnet build` command in our builds has failed with an exit code of -1. The command returns no output. The command writes no logs, even when passed command line parameters to do so. We had to pin our builds to .NET 8 SDK.

Strangely, sometimes if we keep retrying the `dotnet build` command, it will eventually succeed, but sometimes even trying repeatedly doesn't work.

### To Reproduce

In Windows PowerShell 5.1, run this PowerShell in a directory that has a .NET solution or .csproj to build.

```powershell
$ErrorActionPreference = 'Stop'

Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -OutFile '.\dotnet-install.ps1' -UseBasicParsing
.\dotnet-install.ps1 -Channel '10.0'
.\dotnet-install.ps1 -Channel '6.0' -Runtime 'dotnet'

dotnet build
```

### Exceptions (if any)

```
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: System.Management.Automation.RemoteException
```

### Further technical details
details of dotnet --info

- Visual Studio 2017 18.0.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.