我是编程新手,但不是Linux新手。我最近在C#中开始编程,我们使用Visual Studio 2015来编写应用程序,因此使用MSbuild来编译它们。但是,在家里我想用mono编译所有东西,但是当我尝试时我得到了几个错误并且它拒绝编译。 这是我运行的程序:
$ xbuild Dice_Game.sln
这是stderr:
Errors:
/home/dj/programs/c#_programs/Dice_Game/Dice_Game.sln (default targets) ->
(Build target) ->
/home/dj/programs/c#_programs/Dice_Game/Dice_Game.csproj (default targets) ->
/usr/local/lib/mono/xbuild/12.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->
CSC: error CS0518: The predefined type `System.Object' is not defined or imported
CSC: error CS0518: The predefined type `System.ValueType' is not defined or imported
CSC: error CS0518: The predefined type `System.Attribute' is not defined or imported
CSC: error CS0518: The predefined type `System.Int32' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt32' is not defined or imported
CSC: error CS0518: The predefined type `System.Int64' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt64' is not defined or imported
CSC: error CS0518: The predefined type `System.Single' is not defined or imported
CSC: error CS0518: The predefined type `System.Double' is not defined or imported
CSC: error CS0518: The predefined type `System.Char' is not defined or imported
CSC: error CS0518: The predefined type `System.Int16' is not defined or imported
CSC: error CS0518: The predefined type `System.Decimal' is not defined or imported
CSC: error CS0518: The predefined type `System.Boolean' is not defined or imported
CSC: error CS0518: The predefined type `System.SByte' is not defined or imported
CSC: error CS0518: The predefined type `System.Byte' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt16' is not defined or imported
CSC: error CS0518: The predefined type `System.String' is not defined or imported
CSC: error CS0518: The predefined type `System.Enum' is not defined or imported
CSC: error CS0518: The predefined type `System.Delegate' is not defined or imported
CSC: error CS0518: The predefined type `System.MulticastDelegate' is not defined or imported
CSC: error CS0518: The predefined type `System.Void' is not defined or imported
CSC: error CS0518: The predefined type `System.Array' is not defined or imported
CSC: error CS0518: The predefined type `System.Type' is not defined or imported
CSC: error CS0518: The predefined type `System.Collections.IEnumerator' is not defined or imported
CSC: error CS0518: The predefined type `System.Collections.IEnumerable' is not defined or imported
CSC: error CS0518: The predefined type `System.IDisposable' is not defined or imported
CSC: error CS0518: The predefined type `System.IntPtr' is not defined or imported
CSC: error CS0518: The predefined type `System.UIntPtr' is not defined or imported
CSC: error CS0518: The predefined type `System.RuntimeFieldHandle' is not defined or imported
CSC: error CS0518: The predefined type `System.RuntimeTypeHandle' is not defined or imported
CSC: error CS0518: The predefined type `System.Exception' is not defined or imported
4 Warning(s)
31 Error(s)
Time Elapsed 00:00:01.2374970
似乎我可以完成这项工作......我对Mono的经验不足以使其发挥作用。任何帮助将不胜感激。
答案 0 :(得分:3)
请将项目的目标框架更改为.NET 4.5。
目前,Mono不支持.NET 4.5.1及更高版本。
答案 1 :(得分:0)
把一半的头发拉到这上面。有许多方法可以安装Mono,有些方法会安装过时的版本。我记得遵循VS Code和Omnisharp的一些说明。
因此,要获得最新安装,请按照download page of mono上的说明设置apt源,然后执行:
sudo apt install --reinstall mono-complete
sudo apt upgrade
xbuild
已开始工作,但表示已弃用,因此请使用msbuild
。
答案 2 :(得分:0)
在我的Ubuntu Bionic设置中,此问题已通过安装mono-reference-assemblies-*
软件包进行了修复。
(由于某些原因,它们未与mono-devel
一起安装)