首页 > 代码库 > Visual Studio For MacOS .NetCore开发踩坑记

Visual Studio For MacOS .NetCore开发踩坑记

  自从Visual Studio For  MacOS公布以来,就开始尝试在Mac上进行net core开发。断断续续遇到了各种奇奇怪怪的问题。虽然大部分利用google查查(百度屁都查不出来),都能找到解决方案,但还是做个记录吧~

问题一:

错误提示:error MSB4057: The target “Build” does not exist in the project

记录时间:2017-03-31

原因解析:Mono版本低了。对,就是Mono版本低了,别问我为什么开发netcore和mono怎么扯起来联系的。人家说了:Yes it is a dependency. Currently the updater will not show it as a dependency for technical reasons. Visual Studio (Windows) depends on MSBuild 15 to compile .NET Core projects. Visual Studio for Mac also depends on MSBuild 15 and this is shipped with Mono 4.8. Earlier versions of Mono 4.8 were not including the latest bits to support compiling .NET Core projects。而且这个时间段刚好是netcore项目从xproj文件转为csproj,所以老版本的不兼容。  我查了下我的mono版本的,是16年的版本,虽然也是4.8.但是小版本号不够。升级到最新,问题解决。

参考地址:http://www.mono-project.com/  

     http://stackoverflow.com/questions/41773344/project-not-build-in-active-configuration-visual-studio-macos-net-core 

     http://stackoverflow.com/questions/41788027/visual-studio-macos-error-msb4057-the-target-build-does-not-exist-in-the-proj

 

 

问题二:

错误提示:Unable to attach to CoreCLR.

记录时间:2017-04-01

原因解析:我把macos的版本从10.12.3升级到了10.12.4。这里面出现了一些不兼容。  这已经是第二次因为macos版本升级导致netcore不能用了!

解决方案:

  1. Download https://dotnet.myget.org/F/dotnet-core/api/v2/package/runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR/1.1.2-servicing-25123-01
  2. Open the resulting file as a zip, and copy out runtimes/osx.10.10-x64/native/libdbgshim.dylib
  3. Navigate to /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/DotNetCore.Debugger/Adapter/ in Finder or Terminal
  4. Rename libdbgshim.dylib to libdbgshim.dylib.old
  5. Paste in the new libdbgshim.dylib

参考地址: https://github.com/dotnet/coreclr/issues/10279

                https://github.com/dotnet/core/issues/377 

Visual Studio For MacOS .NetCore开发踩坑记