简体   繁体   中英

Trouble compiling VS2015 application with mono/xbuild

I'm new to programming, but not new to Linux. I recently began a Programming class in C# and we're using Visual Studio 2015 to write applications and therefore MSbuild to compile them. However, at home I'd like to compile everything with mono, but when I try I get several errors and it refuses to compile. This is the program I run:

$ xbuild Dice_Game.sln

and this is 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

It seems like I can make this work... I'm just not experienced enough with Mono to make it work. Any help would be appreciated.

Please change your project's target framework to .NET 4.5.

Currently Mono does not support .NET 4.5.1 and above.

Pulled half of my hair on this. There are many ways to install Mono, and some will install an outdated version. I remember following some instructions for VS Code and Omnisharp.

So, to get an up to date installation, follow the instructions on the download page of mono to set up the apt source, then do:

sudo apt install --reinstall mono-complete
sudo apt upgrade

xbuild started working but said it was deprecated so use msbuild .

on my Ubuntu Bionic setup this was fixed by installing the mono-reference-assemblies-* packages. (for some reason they are not installed with mono-devel )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM