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

-p:DebugSymbols=false does not disable generation of .pdb files #41364

Open
jkotas opened this issue May 19, 2024 · 6 comments
Open

-p:DebugSymbols=false does not disable generation of .pdb files #41364

jkotas opened this issue May 19, 2024 · 6 comments
Assignees

Comments

@jkotas
Copy link
Member

jkotas commented May 19, 2024

Describe the bug

https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2022 states:

Setting -p:DebugSymbols=false on the command line disables generation of program database (.pdb) symbol files.

This does not match .NET 8 SDK behavior.

-p:DebugType=None is the actual property that can be used to disable the .pdb symbol generation.

DebugSymbols property should be either documented as obsolete and no longer supported with DebugType as recommended replacement; or the behavior DebugSymbols property should be fixed to match the documentation.

To Reproduce

dotnet new console
dotnet build -p:DebugSymbols=false
dir /s *.pdb

Actual result: .pdb file is generated
Expected result: No .pdb file is generated

Further technical details

.NET SDK 8.0.205

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels May 19, 2024
@jkotas jkotas changed the title -p:DebugSymbols=false does not disable .pdb files -p:DebugSymbols=false does not disable generation of .pdb files May 19, 2024
@Forgind
Copy link
Member

Forgind commented May 28, 2024

MSBuild owns DebugSymbols; would you mind taking a first look?

@Forgind Forgind removed their assignment May 28, 2024
@Forgind Forgind transferred this issue from dotnet/sdk May 28, 2024
@Forgind Forgind added needs-triage and removed Area-NetSDK untriaged Request triage from a team member labels May 28, 2024
@rainersigwald
Copy link
Member

The compiler is passed both

EmitDebugInformation = False
DebugType = portable

and produces this part of the command line

/debug- /debug:portable

The csc help doesn't specify a precedence here but manually swapping those changes the behavior to

&"C:\Program Files\dotnet\dotnet.exe" exec "C:\Program Files\dotnet\sdk\8.0.300\Roslyn\bincore\csc.dll" /noconfig `@foo.rsp
Microsoft (R) Visual C# Compiler version 4.10.0-3.24216.12 (3af0081a)
Copyright (C) Microsoft Corporation. All rights reserved.

error CS2045: /embed switch is only supported when emitting a PDB.

@jaredpar would you say we should treat this as a Csc task bug (allows passing multiple contradictory params without warning), an SDK bug (doesn't respect DebugSymbols when setting other properties, resulting in the contradictory params), or a doc bug?

@jaredpar
Copy link
Member

allows passing multiple contradictory params without warning

The compilers have long allowed for contradictory params to be provided. There are ample tests in the native and Roslyn compiler to ensure we handle contradictory parameters correctly. Not my preferred design but it's very much baked into how the compiler operates.

The csc help doesn't specify a precedence here but manually swapping those changes the behavior to

Unless stated otherwise the last switch wins.

@rainersigwald
Copy link
Member

At the compiler CLI layer I think that's fine and wouldn't want to change at this point, but at the task layer there's no user control over order so they're at the mercy of what the task chooses.

(I lean toward "this is an SDK bug" personally)

@jaredpar
Copy link
Member

Yeah if we want universal behavior for all the languages then feels like something that should be handled at the SDK layer. Basically normalize out the properties so that all the compilers don't have to individually do this work.

@Forgind
Copy link
Member

Forgind commented Jun 3, 2024

Ah, I'd assumed we were just passing information to MSBuild, and it was getting mangled either there or at the compiler. It sounds like the problem is that we look for a particular property and pass a default value if it isn't present but won't notice an alternate way of expressing a similar concept. Does that sound right? If so, I think I'd agree that this is probably best resolved in the SDK layer by not expressing that.

Looking around, this seems by far the most likely culprit:

<DebugType Condition=" '$(DebugType)' == '' ">portable</DebugType>

I can change that to set DebugType to None if DebugSymbols is set to false if that sounds reasonable to you.

@rainersigwald rainersigwald transferred this issue from dotnet/msbuild Jun 3, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Jun 3, 2024
@Forgind Forgind self-assigned this Jun 4, 2024
@Forgind Forgind removed untriaged Request triage from a team member needs-triage labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants