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

"csc.dll" exited with code 1 instead of compilation error details, under Linux only #43592

Open
JonathanLydall opened this issue Sep 20, 2024 · 1 comment
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@JonathanLydall
Copy link

Describe the bug

When using dotnet build on Linux the output shows only "csc.dll" exited with code 1 instead of the actual compilation issue. On Windows the actual compilation issue is shown.

To Reproduce

On Linux (tested on WSL with Ubuntu 22.04):

  • git clone https://github.com/JonathanLydall/dotnet_build_bug.git
  • dotnet build

Successful compilation:

  • git checkout fixed
  • dotnet build

Exceptions (if any)

Receive the following error only with the build:

/usr/share/dotnet/sdk/9.0.100-rc.1.24452.12/Roslyn/Microsoft.CSharp.Core.targets(89,5): error MSB6006: "csc.dll" exited with code 1.
Full console output

PS /home/jonathan/dev/dotnet_build_bug> dotnet build
Restore complete (0.4s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  Intent.Modules.ModuleBuilder failed with 1 error(s) and 7 warning(s) (0.5s)
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Templates/Api/ApiElementExtensionModel/ApiElementExtensionModelTemplatePartial.cs(86,36): warning CS0108: 'ApiElementExtensionModelTemplate.DeclareUsings()' hides inherited member 'CSharpTemplateBase<ElementExtensionModel>.DeclareUsings()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Templates/Api/ApiElementModelExtensions/ApiElementModelExtensionsTemplatePartial.cs(52,36): warning CS0108: 'ApiElementModelExtensionsTemplate.DeclareUsings()' hides inherited member 'CSharpTemplateBase<ExtensionModel>.DeclareUsings()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Api/AssociationEventHandlerModel.cs(26,33): warning CS0108: 'AssociationEventHandlerModel.ToPersistable()' hides inherited member 'ScriptModel.ToPersistable()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Api/ElementEventHandlerModel.cs(49,33): warning CS0108: 'ElementEventHandlerModel.ToPersistable()' hides inherited member 'ScriptModel.ToPersistable()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Templates/Registration/FilePerModel/FilePerModelTemplateRegistrationTemplatePartial.cs(66,36): warning CS0108: 'FilePerModelTemplateRegistrationTemplate.DeclareUsings()' hides inherited member 'CSharpTemplateBase<TemplateRegistrationModel>.DeclareUsings()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Templates/Registration/SingleFileListModel/SingleFileListModelTemplateRegistrationTemplatePartial.cs(66,36): warning CS0108: 'SingleFileListModelTemplateRegistrationTemplate.DeclareUsings()' hides inherited member 'CSharpTemplateBase<TemplateRegistrationModel>.DeclareUsings()'. Use the new keyword if hiding was intended.
    /home/jonathan/dev/dotnet_build_bug/Intent.Modules.ModuleBuilder/Api/RunScriptOptionModel.cs(50,32): warning CS0108: 'RunScriptOptionModel.ToPersistable()' hides inherited member 'ScriptModel.ToPersistable()'. Use the new keyword if hiding was intended.
    /usr/share/dotnet/sdk/9.0.100-rc.1.24452.12/Roslyn/Microsoft.CSharp.Core.targets(89,5): error MSB6006: "csc.dll" exited with code 1.

Build failed with 1 error(s) and 7 warning(s) in 1.1s

However, when run on Windows you see the proper error details:

C:\Dev\Intent.Modules\Modules\Intent.Modules.ModuleBuilder\Templates\Api\ApiElementModel\ApiElementModelTemplate.tt(2,78): error CS0426: The type name 'ModuleBuilder' does not exist in the type 'Intent' [D:\De
v\Spikes\VS\dotnet_build_bug\Intent.Modules.ModuleBuilder\Intent.Modules.ModuleBuilder.csproj]
C:\Dev\Intent.Modules\Modules\Intent.Modules.ModuleBuilder\Templates\Api\ApiElementModel\ApiElementModelTemplate.tt(2,26): error CS0263: Partial declarations of 'ApiElementModelTemplate' must not specify diffe
rent base classes [D:\Dev\Spikes\VS\dotnet_build_bug\Intent.Modules.ModuleBuilder\Intent.Modules.ModuleBuilder.csproj]

Further technical details

dotnet --info

PS /home/jonathan/dev/dotnet_build_bug> dotnet --info
.NET SDK:
 Version:           9.0.100-rc.1.24452.12
 Commit:            81a714c6d3
 Workload version:  9.0.100-manifests.a7bf2b8f
 MSBuild version:   17.12.0-preview-24422-09+d17ec720d

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/9.0.100-rc.1.24452.12/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      9.0.0-rc.1.24431.7
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  8.0.200 [/usr/share/dotnet/sdk]
  9.0.100-rc.1.24452.12 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

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

Download .NET:
  https://aka.ms/dotnet/download

Additional context

Initially I didn't get any compilation errors on Windows, dotnet build and compiling in VS 2022 would complete without error, I only noticed a problem when it was building on an Azure Pipelines hosted Linux agent.

Testing on WSL Ubuntu 22.04 with .NET 8 reproduced the same error, rolling back just this change seemed to avoid the problem.

When I was trying to make a simpler reproduction repository I eventually saw the CS0426: The type name 'ModuleBuilder' does not exist in the type on Windows and resolving it there resolved the issue on Linux.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Sep 20, 2024
JonathanLydall added a commit to IntentArchitect/Intent.Modules that referenced this issue Sep 20, 2024
@KalleOlaviNiemitalo
Copy link

ApiElementModelTemplate.cs includes #line directives with Windows-format file paths, which then get copied into compiler error messages. I wonder if those somehow confuse the logging on Linux, which expects a different path format.

If you build with --tl:off on Linux (or set MSBUILDTERMINALLOGGER=off in the environment), does it display the error message correctly then? I expect it doesn't; although TerminalLogger highlights the file name in error messages, it does that in a way that tolerates unexpected path formats.

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
@JonathanLydall @KalleOlaviNiemitalo and others