Open rainersigwald opened 5 years ago
Still happening using mcr.microsoft.com/dotnet/sdk:5.0
$ dotnet --version
5.0.401
$ dotnet nuget --version
NuGet Command Line
5.11.0.10
$ dotnet build -c Release --output ../app/
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
/builds/.nugetcache/microsoft.net.compilers/3.11.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB3883: Unexpected exception: [/Tools/SourceGenerator/SourceGenerator.csproj]
/builds/.nugetcache/microsoft.net.compilers/3.11.0/tools/Microsoft.CSharp.Core.targets(71,5): error : Exec format error [/Tools/SourceGenerator/SourceGenerator.csproj]
Thanks to @rainersigwald I was able to fix it by adding "Microsoft.Net.Compilers.Toolset" Version="3.11.0"
my project looked like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="3.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.11.0" />
<PackageReference Include="Microsoft.Net.Compilers" Version="3.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
I had a similar issue, adding these to my Directory.Build.props
<PackageReference Include="Microsoft.Net.Compilers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
With this in my Directory.Packages.props
<PackageVersion Include="Microsoft.Net.Compilers" Version="4.0.1" />
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.0.1" />
Appears to have resolved my csc errors on MacOS
I had a similar issue, adding these to my Directory.Build.props
<PackageReference Include="Microsoft.Net.Compilers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.Net.Compilers.Toolset"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
With this in my Directory.Packages.props
<PackageVersion Include="Microsoft.Net.Compilers" Version="4.0.1" /> <PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.0.1" />
Appears to have resolved my csc errors on MacOS
You just saved my day!
Version Used: 3.3.0
Steps to Reproduce:
Add a NuGet package reference to
Microsoft.Net.Compilers
and attempt to build on .NET Core on non-Windows.crash-on-compiler-package.zip
Expected Behavior:
No crash.
Actual Behavior:
It's not obvious from this logging, but the problem is that the
Csc
task is attempting to directly invokecsc.exe
, a Windows/desktop framework executable.The correct package to use is
Microsoft.Net.Compilers.Toolset
. But it would still be nice to have a clear "You can't use this package on .NET Core; useMicrosoft.Net.Compilers.Toolset
instead" error instead of this crash.This could be considered part of https://github.com/dotnet/roslyn/issues/33695.
(encountered by @sharwell in https://github.com/microsoft/vs-threading/pull/539; we root caused it offline)