I'm looking to install MSBuild on my Linux laptop so I can build a C# OSS project of mine. How exactly would I go about doing this? I've come across a few guides such as this which suggest installing the MSBuild NuGet package, but it doesn't seem official or actively maintained.
Is there an official package source I can install MSBuild from?
Yes, there is such a package hosted by the CoreFX team as a MyGet feed. To install, run this at a terminal:
#!/bin/sh
packageid="Microsoft.Build.Mono.Debug"
version="14.1.0.0-prerelease" # update as needed
mono path/to/nuget.exe install $packageid -Version \
$version -Source "https://www.myget.org/F/dotnet-buildtools/"
# run MSBuild
mono $packageid.$version/lib/MSBuild.exe Foo.sln
Technically this should be used only for building the .NET Core repos, but I'll take it as an alternative to an unofficial publisher.
Source.
EDIT: Note that this will only work if your version of Mono is 4.0.1 or above.
A pretty easy way to do it now is using the dotnet docker images:
https://hub.docker.com/_/microsoft-dotnet-sdk/
https://github.com/dotnet/dotnet-docker/blob/main/samples/build-in-sdk-container.md
Related
I'm trying to install MonoGame for mac and VS code. I followed the instructions at https://docs.monogame.net/articles/getting_started/1_setting_up_your_development_environment_macos.html, but I am stuck at one place. I have the monogame editor .mpack file, but can't upload it to VS code for some reason. I did extensive research but can't find any answers. What should I do?
The "normal" Mac install instructions and files are only for use with Visual Studio.
Install using CLI
Please note these instructions are designed for Intel Macs(x64), but should work on Apple Silicon devices(ARM) with .Net6.
You can roughly follow the Linux install instructions.
Install Dot Net Core 3.1 for the Mac. or .Net6
Install VS Code.
You may need to reference this question on Terminal paths for code. Something similar may need to be done below for the dotnet command.
a. Install the C# extensions: code --install-extension ms-dotnettools.csharp
(Optional) Install Mono. Required for some consoles and Android targets(Frameworks 4.5 and 4.7). See here for compatability.
Open a terminal window. Run the following line, either the OS or from VS Code:
dotnet new --install MonoGame.Templates.CSharp
The next two lines may be Linux specific so ignore any uncorrectable errors.
dotnet tool install --global dotnet-mgcb-editor
mgcb-editor --register
At this point, you should be able to create a new CLI project folder from the templates:
cd /path/togame/parent
dotnet new mgdesktopgl -o MyGame
Open the folder in VS Code.
Review the projectname.csproj file:
Note the TargetFramework line:
<TargetFramework>netcoreapp3.1</TargetFramework> or
<TargetFramework>net6.0</TargetFramework>
Some targets require a different TargetFramework, like net47 or net45 as provided by Mono.
See Microsoft's .Net versioning page for more information.
A couple of additional helpful CLI commands to run from the folder with the .proj file; Taken from this list:
dotnet restore Update all NuGet Packages
dotnet clean Remove all output files
dotnet build compile
dotnet run execute the program
I have tried creating asp project using either dotnet cli or visual studio 2017, any time i try to run the project in both cases, i get this strange error.
this how how i created a sample angular project. dotnet new angular in a folder
called angular
Angular.csproj: [NU1202] Package
Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 is not
compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package
Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 supports:
netstandard2.0 (.NETStandard,Version=v2.0)
Seems like this may have been a bug with this specific version of Dot Net core, I found this thread:
https://rider-support.jetbrains.com/hc/en-us/community/posts/115000759144-Compile-Microsoft-CSharp-Core-targets-84-5-MSB6004-C-Program-Files-dotnet-sdk-2-1-2-Roslyn-RunCsc-cmd-
Which suggests copying the RunCsc.cmd from C:\Program Files\dotnet\sdk\2.1.4\Roslyn\bincore to C:\Program Files\dotnet\sdk\2.1.4\Roslyn
I would suggest to check the installation of your dot net core, this seems very weird.
Hope this helps
finally this is what worked for me
dotnet nuget locals all --clear
Does anybody knows which Nuget package contains Microsoft.VisualStudio.LanguageServices.CSharp.dll?
This DLL should be part of the Roslyn project e.g.:
http://sourceroslyn.io/#Microsoft.VisualStudio.LanguageServices.CSharp/CodeModel/Interop/ICSAutoImplementedPropertyExtender.cs
but it looks like it is not installed either in Microsoft.Net.Compilers 2.3.0 or in Microsoft.VisualStudio.LanguageServices.
Thanks in advance.
Marw
MSDN says it is located in the Microsoft.VisualStudio.Package.LanguageService.14.0 assembly.
This link should also be helpful:
.NET Compiler Platform ("Roslyn") support for Visual Studio.
Supported Platforms:
.NET Framework 4.6
To install Microsoft.VisualStudio.LanguageServices, run the following command in the Package Manager Console:
Install-Package
Microsoft.VisualStudio.LanguageServices -Version 2.2.0
I believe it is contained within a Nuget package called Microsoft.VisualStudio.LanguageServices.
Instructions on how to install the package, as quoted from https://github.com/dotnet/roslyn
To install the latest release without Visual Studio, run one of the
following nuget command lines:
nuget install Microsoft.Net.Compilers # Install C# and VB compilers
nuget install Microsoft.CodeAnalysis # Install Language APIs and
Services
I have installed Mono 3 however when I run xsp or xsp4 it shows that I'm using .NET 4.0. I need to have .NET 4.5. Is it possible? Where can I configure it?
I've seen this page but I don't have any of those folders where I downloaded sources.
This is what it shows when I enter website by running xsp4:
Version Information: 3.2.7 (master/1eef047 C nov 28 18:16:30 EET 2013); ASP.NET Version: 4.0.30319.17020
How I installed Mono and XSP
Firstly I downloaded Lubuntu 13.10 32bit and launched it inside VirtualBox. Then did apt-get update and apt-get upgrade. After that rebooted the system.
Make sure all commands are executed as super user.
sudo -s
Got dependencies
apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libpng12-dev libfontconfig1-dev mono-gmcs git
Downloaded sources of Mono and XSP
cd /opt
git clone git://github.com/mono/mono.git
git clone git://github.com/mono/xsp.git
Installed latest stable Mono from github
cd /opt/mono
./autogen.sh --prefix=/usr
make
make install
Installed latest stable XSP from github
cd /opt/xsp
./autogen.sh --prefix=/usr
make
make install
Tested that I have 4.0 running on XSP instead of 4.5
cd /home/pc/web
xsp4 # 4.0
xsp2 # 2.0
xsp # 2.0
My configuration
/usr/bin/xsp4 looks like it should use 4.5. Just like this answer suggested. Also, I don't have xsp4.exe in my /usr/lib/mono/4.0/ only in /usr/lib/mono/4.5/ so I cannot copy anything like suggested in that answer.
#!/bin/sh
exec /usr/bin/mono $MONO_OPTIONS "/usr/lib/mono/4.5/xsp4.exe" "$#"
You say "I don't have any of those folders where I downloaded sources" referring to /opt/mono/bin/xsp4. But you're confusing things, and I know it because you shared how you installed mono.
/opt/mono should not be the place where you clone the mono repository to compile it. You should clone it somewhere else like your home folder. I.e.: /home/username/code/mono.
/opt/mono is where usually people install a custom version of mono. The way they do it is passing this path to the --prefix argument. But you're passing /usr as the prefix argument! So then you're installing it to a different location compared to the SO answer that you point out.
Also, it is not recommended that you do ALL those operations as a superuser. You normally compile code without root privileges, and you only need sudo for the install phase. So don't do "sudo -s" before everything. Just compile, and when you're done, do sudo make install. This will also make you have binaries that are not owned by root.
I have followed the instructions on the G-WAN site FAQ and read through the manual, but I can not get G-WAN to "see" the Mono installation on my Debian 6 (x64) setup.
I have tried with the recommended Mono version (3.0.2) and the latest(3.0.4).
I am using the latest (today's) version of G-WAN.
Have I missed some configuration (e.g. environment variables...) or do I need to run Mono as a daemon?
mono by default installs on "/usr/local".
Compiling mono 3.0.6 using
./configure --prefix=/usr
make
make install
Worked for me. It will install libmono*.so on "/usr/lib"
G-WAN searches libmono*.so under /usr/lib and then links dynamically with it to compile C# scripts.
If you have installed Mono elsewhere then you should either provide links or re-build and install Mono (from source code) in the proper directory (which is simpler to do).
You can verify where Mono is installed by running:
find -L /usr/lib -name 'libmono*.so'
/usr/lib/libmono-2.0.so