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

南楼画角 提交于 2020-11-30 11:08:23

问题


Just downloaded Visual Studio Professional for Mac and I cannot seem to build anything as I always get the same error:

/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)

Not sure what to change on my project to get things to compile.


回答1:


I was able to work around this problem two ways:

  1. HACK By removing debug symbols from the build (in VS windows: Project Properties -> Build Tab -> Advanced button -> change "Debug Info" dropdown to "none" -- not sure what equivalent is in VS for Mac / Xamarin Studio) I did this for all configurations of affected project(s). Pulled back to macOS env, build now succeeds. No debug info of course, but it works without breaking any deps.

  2. NON-HACK Root cause is the use of Roslyn compiler/tools for ASP.NET Web projects, and this tool produces PDB files instead of MDB files, and the build fails trying to produce PDB files on macOS platform (er go "platform unsupported".) Knowing the root cause we can also remove the following nuget packages from the affected projects:

    <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" />
    

It's unclear what is sacrificed by removing these two packages. This does allow me to build the affected projects with the debug info included. The affected projects only contained webapi endpoints, and no use of MVC nor Razor engine. It would be nice to hear the experiences of others if they had issues upstream from this change.

HTH




回答2:


This is a bug that will be fixed shortly. Meanwhile, you can edit your csproj file to add

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

after the line with <DebugType>full</DebugType> or <DebugType>pdbonly</DebugType>

Essentially, we want the DebugType property on Mac to be portable, which is supported by Roslyn's csc.exe on non-windows platforms, instead of pdb.




回答3:


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"




回答4:


After I deleted the line

<DebugType>pdbonly</DebugType>

from the .csproj file, the build became successful.




回答5:


I hope not to come too late, I did the following to solve the problem:

  1. Right click in the solution and select "Options",

  2. Select tab Build -> Configurations,

  3. In "Configuration A." select "Debug" and disable all builds marks and click accept,

  4. Clean, rebuild and execute project.

I hope this helps.



来源:https://stackoverflow.com/questions/40639999/csc-error-cs0041-unexpected-error-writing-debug-information-operation-is-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!