Linux: Compilation errors on lines with #line directives with Windows paths shows "csc.dll" exited with code 1 instead of the actual compilation error
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
On Linux, when a compilation issue occurs on a line with a `#line` directive above it with a Windows path, MSBuild output shows only `"csc.dll" exited with code 1` instead of the actual compilation issue.
### 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:
```text
/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.
```
### Further technical details
dotnet --info
```text
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
```
### Original bug report
The below is the original bug report before @KalleOlaviNiemitalo pointed out the root cause and I then simplified the reproduction steps above, it's probably irrelevant now but can still be reviewed if desired.
Original bug report
### 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:
```text
/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.
```
```text
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.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.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.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.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:
```text
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]
```
#### 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](https://github.com/IntentArchitect/Intent.Modules/commit/dfc2289bb681bb145645c7e3684afb47ba01d695#diff-d0516a4def72405703d400d27ee897ff1605f2983bc40f884c42b3c07a861085R17) 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.