.net - 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>
```
解决方案
当我尝试从 VS Code 而不是 Visual Studio(macOS 环境)构建我的项目时,我遇到了这个问题。经过一些不成功的研究,我刚刚删除了对Microsoft.Net.Compilers
删除它后,我可以从 VS Code 和 Visual Studio for MAC 运行、构建和调试。
我希望它有所帮助。
推荐阅读
- java - 如何使用 gradle 构建包含多个 java 模块的单个 jar 文件?
- python - 重新加载对象的@property-decorated 方法
- r - 如何在ar循环中运行函数
- javascript - html2canvas 中的文字只显示一行
- c# - 如何将不连续的单元格范围从 Excel 传递到 ExcelDNA 函数
- symfony - Symfony 4 - 使用 KnpPaginatorBundle 进行多分页渲染?
- java - 谷歌云 - 与本地机器相比,数据存储区太慢了
- node.js - 有没有办法在同一个域/服务器上运行用不同语言编写的完全不同的项目?
- php - 计数我做了一个 preg_replace 我通过字典运行匹配并将其用作放置的项目?
- python - 如何在具有下拉菜单且包含日期的 bigquery 中打开数据集