Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotnet build does not set correct exit code when used with -graph parameter #37224

Closed
bording opened this issue Nov 29, 2023 · 3 comments
Closed
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@bording
Copy link

bording commented Nov 29, 2023

Describe the bug

When dotnet build -graph is used to build a project that fails, the exit code stays 0 instead of being a non-zero value.

dotnet msbuild -graph correctly sets a non-zero exit code.

To Reproduce

  • dotnet new console
  • Edit Program.cs to introduce a compiler error (for example Console.Wri teLine("Hello, World!");)
  • Check the error code for each of the following commands:
    • dotnet build (exit code 1)
    • dotnet build -graph (exit code 0)
    • dotnet msbuild -graph (exit code 1)

Exceptions (if any)

N/A

Further technical details

dotnet --info

 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.8d38d0cc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

.NET workloads installed:
 Workload version: 8.0.100-manifests.8d38d0cc
There are no installed workloads to display.

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  8.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Nov 29, 2023
@marcpopMSFT marcpopMSFT self-assigned this Dec 5, 2023
@bording
Copy link
Author

bording commented Dec 6, 2023

I have some additional info related to this. It looks like it might actually be MSBuild itself that is the problem. I have now also been able to reproduce the problem with .NET Framework MSBuild.exe. It appears that the problem combination is using -restore and -graph together.

Since dotnet build implicitly calls MSBuild with -restore but dotnet msbuild doesn't, this explains the original behavior I was seeing.

dontnet msbuild -restore -graph reports a 0 exit code as well.

@baronfel
Copy link
Member

baronfel commented Dec 6, 2023

Oh! This is a dupe of an already logged MSBuild bug that is being fixed right now in dotnet/msbuild#9461

@bording
Copy link
Author

bording commented Dec 6, 2023

Oh! This is a dupe of an already logged MSBuild bug that is being fixed right now in dotnet/msbuild#9461

That's good to hear! If I had realized the full scope of the problem when I opened the issue, I would have started at the MSBuild repo instead and maybe caught that myself.

I'll go ahead and close this issue then.

@bording bording closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants