【问题标题】:Mono MSBuild error after installing reference assemblies Ubuntu 18.04安装参考程序集 Ubuntu 18.04 后 Mono MSBuild 错误
【发布时间】:2018-11-26 17:43:08
【问题描述】:

我想在 Ubuntu 18.04 上的 Mono 中构建一个 .net framework 4.7.2 项目

我根据本指南安装了 mono-devel: https://www.mono-project.com/download/stable/

在我的一个项目上安装并尝试运行 msbuild 后,我收到此错误:

/usr/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(1195,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. 

我找到了我安装的参考程序集包: mono-reference-assemblies-4.0

安装包并再次运行构建后,我收到以下错误:

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x000bb] in <0fd2831d9cb34830af9027441f77a417>:0 

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x003f2] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Main () [0x00028] in <0fd2831d9cb34830af9027441f77a417>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x003f2] in <0fd2831d9cb34830af9027441f77a417>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Main () [0x00028] in <0fd2831d9cb34830af9027441f77a417>:0 

无论我从哪里运行msbuild,都会发生此错误。看来应该可以构建我的项目了。

任何帮助将不胜感激。

【问题讨论】:

  • 你是如何安装单声道的?这看起来像您在安装新版本之前安装了以前版本的单声道(4.6.2);在安装我认为的新版本之前,您必须删除任何与单声道相关的软件包
  • 或者包mono-reference-assemblies-4.0来自旧版本;要仔细检查这一点,您需要知道该软件包来自哪个 apt 源;也许apt-cache 会给你这个信息?
  • @knocte mono-reference-assemblies-4.0 来自宇宙,mono-devel 是从我按照上面提到的说明添加的单声道项目 repo 安装的。我似乎无法在其他地方找到参考程序集。
  • 单包版本:5.16.0.179-0xamarin1+ubuntu1804b1,单参考程序集版本:3.12.1+dfsg-2
  • 这就是问题所在,您将 3.x 与 5.x 包混合在一起

标签: msbuild mono ubuntu-18.04


【解决方案1】:

mono-reference-assemblies-4.0 软件包不是来自您为安装新版本 Mono 而添加的新 apt 源的稳定通道,因此您在运行时混合了 Mono 版本,这导致了那些奇怪的异常.

解决办法是卸载这个包并切换到不稳定频道(因为.NET 4.7.2 对于稳定版来说太新了)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 2020-08-01
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多