16

刚刚下载了 Visual Studio Professional for Mac,我似乎无法构建任何东西,因为我总是遇到同样的错误:

/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->

CSC: error CS0041: Unexpected error writing debug information -- 'Operation is not supported on this platform.'

 19 Warning(s)
 1 Error(s)

不知道要对我的项目进行哪些更改才能编译。

4

5 回答 5

22

我能够通过两种方式解决这个问题:

  1. HACK通过从构建中删除调试符号(在 VS 窗口中:项目属性 -> 构建选项卡 -> 高级按钮 -> 将“调试信息”下拉列表更改为“无”——不确定 VS for Mac / Xamarin Studio 中的等效项)我对受影响项目的所有配置都这样做了。拉回 macOS 环境,现在构建成功。当然没有调试信息,但它可以在不破坏任何部门的情况下工作。

  2. NON-HACK根本原因是对 ASP.NET Web 项目使用 Roslyn 编译器/工具,并且此工具生成 PDB 文件而不是 MDB 文件,并且构建尝试在 macOS 平台上生成 PDB 文件失败(呃“平台不受支持” .) 了解根本原因后,我们还可以从受影响的项目中删除以下 nuget 包:

    <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net45" />
    <package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
    

目前尚不清楚删除这两个软件包会牺牲什么。这确实允许我构建包含调试信息的受影响项目。受影响的项目仅包含 webapi 端点,没有使用 MVC 或 Razor 引擎。如果他们在此更改的上游遇到问题,很高兴听到其他人的经验。

高温高压

于 2016-11-16T19:27:21.623 回答
7

这是一个很快就会修复的错误。同时,您可以编辑您的 csproj 文件以添加

<DebugType Condition="'$(OS)' != 'Windows_NT'">portable</DebugType>

<DebugType>full</DebugType>或之后<DebugType>pdbonly</DebugType>

本质上,我们希望DebugTypeMac 上的属性是,Roslyn在非 Windows 平台上portable支持该属性,而不是.csc.exepdb

于 2016-11-18T01:15:12.207 回答
5

To solve this problem you need to do :

  1. Select project

  2. Right click and select options

  3. Select tab Build -> Compiler
  4. Debug information -> None

It solved this error but gives me another one

"System.IO.FileNotFoundException Could not find file "/Users/.../.../bin\roslyn\csc.exe"

于 2016-12-10T22:41:55.387 回答
1

在我删除该行之后

<DebugType>pdbonly</DebugType>

.csproj文件中,构建成功。

于 2019-05-30T07:59:19.227 回答
0

我希望不要来得太晚,我做了以下来解决问题:

  1. 右键单击解决方案并选择“选项”,

  2. 选择选项卡构建 -> 配置,

  3. 在“配置 A”中。选择“调试”并禁用所有构建标记并单击接受,

  4. 清理、重建和执行项目。

我希望这有帮助。

于 2019-01-22T01:02:01.780 回答