首页 > 解决方案 > dotnet rosalyn 编译器错误 MSB6006:“csc.exe”以代码 8 退出

问题描述

在尝试运行 dotnet build 命令时,我在 amazon linux 中遇到了这个错误。我正在尝试使用 sonarqube .net 核心扫描仪,并将其作为运行 dotnet build 命令的一部分。

sudo dotnet build --no-restore --verbosity d --no-dependencies
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 11/27/18 11:42:22 AM.
1>Project "/var/lib/jenkins/workspace/multibranch_pipeline_master-VFQZN2R7JTITZDJOVBS6UDCECP2XJL7TD55373F64OTKZXE63T4Q/source/WebServer/UP/DotNetAPI/DotNetAPI.csproj" on node 1 (Build target(s)).
1>Building with tools version "15.0".
Project file contains ToolsVersion="". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="15.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
1>Target "Build" in project "/var/lib/jenkins/workspace/multibranch_pipeline_master-VFQZN2R7JTITZDJOVBS6UDCECP2XJL7TD55373F64OTKZXE63T4Q/source/WebServer/UP/DotNetAPI/DotNetAPI.csproj" (entry point):
Using "Csc" task from assembly "/opt/dotnet/sdk/2.0.0/Roslyn/Microsoft.Build.Tasks.CodeAnalysis.dll".
Task "Csc"
/opt/dotnet/sdk/2.0.0/Roslyn/csc.exe /out:/DotNetAPI.dll /target:library ReliabilityMain.cs
1>/var/lib/jenkins/workspace/multibranch_pipeline_master-VFQZN2R7JTITZDJOVBS6UDCECP2XJL7TD55373F64OTKZXE63T4Q/source/WebServer/UP/DotNetAPI/DotNetAPI.csproj(10,5): error MSB6006: "csc.exe" exited with code 8.
Done executing task "Csc" -- FAILED.
1>Done building target "Build" in project "DotNetAPI.csproj" -- FAILED.

我的 .csproj 文件如下所示

```
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
 </PropertyGroup>
  <ItemGroup>  
    <Compile Include="ReliabilityMain.cs"/>
    <PackageReference Include="Microsoft.Net.Compilers" Version="2.4.0" />
  </ItemGroup>  
  <Target Name="Build">  
    <Csc Sources="@(Compile)"
    TargetType="library"
     OutputAssembly="$(builtdir)\$(MSBuildProjectName).dll"
    />    
  </Target>  
</Project>  
```

标签: .netmsbuild.net-core

解决方案


当我尝试从 VS Code 而不是 Visual Studio(macOS 环境)构建我的项目时,我遇到了这个问题。经过一些不成功的研究,我刚刚删除了对Microsoft.Net.Compilers

删除它后,我可以从 VS Code 和 Visual Studio for MAC 运行、构建和调试。

我希望它有所帮助。


推荐阅读