dotnet rosalyn编译器错误MSB6006:“ csc.exe”退出,代码为8

时间:2018-11-27 12:49:41

标签: .net msbuild .net-core

在尝试运行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>  
```

1 个答案:

答案 0 :(得分:0)

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

的引用

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

希望对您有帮助。