MonoDevelop 无法导入 VS2013/2015 个解决办法

MonoDevelop can't import VS2013/2015 solutions

我正在打开一个从 VS2013 传输到 MonoDevelop 的 .sln 文件。然而,当我尝试这样做时,它给了我以下错误:

1. Project 'foo' has a different ToolsVersion than the containing solution.
2. Error while trying to load the project '/path/to/foo.csproj': Unknown ToolsVersion '12.0'
3. [repeat 2 for every project in the solution]

当我尝试对 VS2015 文件执行此操作时,我遇到了同样的错误,只是这次 ToolsVersion14.0

我的MonoDevelop版本是v4.0.12;有解决办法吗?

我知道 MonoDevelop 5.x+ / Mono 4.x xbuild/MSBuild 支持 Toolsversion 12。所以让我们检查你的安装。

检查单声道安装:

单声道--版本

Mono JIT compiler version 4.0.2 ((detached/c99aa0c Thu Jun 11 18:53:01 EDT 2015)

xbuild --version

XBuild Engine Version 12.0
Mono, Version 4.0.2.0**

检查您的 GAC 安装:

gacutil -l |grep Microsoft.Build

Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Engine, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Engine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Engine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

检查您是否有 MSBuild dll(路径也依赖于平台,根据需要更改):

cat `which xbuild`

#!/bin/sh
exec /Library/Frameworks/Mono.framework/Versions/4.0.2/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/12.0/bin/xbuild.exe "$@"

从上面的输出中获取您的 Mono 安装路径并更改下面的路径以匹配:

找到/Library/Frameworks/Mono.framework/Versions/4.0.2 -name "*MSBuild"

/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/4.5/MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/policy.0.2.Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/policy.0.3.Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/policy.0.4.Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/policy.0.5.Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/gac/policy.0.6.Mono.Addins.MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/12.0/bin/MSBuild
/Library/Frameworks/Mono.framework/Versions/4.0.2/lib/mono/xbuild/14.0/bin/MSBuild

如您所见,我的工具版本为 12。根据需要更新您的安装/重新安装 ;-)

解决方法是:

  1. 升级到支持使用工具版本 12.0 的项目的 MonoDevelop 5
  2. 编辑 .csproj 文件并将工具版本更改为 4.0

    <项目工具版本="4.0"

如果您选择 2. 那么您将不得不查看此更改后项目是否仍在构建。