Is it possible to install a C# compiler without Vi

2019-01-07 07:55发布

I want to build projects from the command line. Is it possible to deploy a C# compiler without installing Visual Studio?

11条回答
来,给爷笑一个
2楼-- · 2019-01-07 08:19

Of course. Do:

sudo apt-get install mono-gmcs

Everyone else assumed Windows and MS .NET, but...

查看更多
\"骚年 ilove
3楼-- · 2019-01-07 08:19

I was just looking for a solution like this so that I could just make small console applications using C#.

The method that worked for me was mentioned by Brian, all I did was, after creating my file to simply do:

C:\WINDOWS\Microsoft.NET\Framework\v[your version number]\csc.exe myfile.cs

and it will generate your .exe file that you can then use :)

查看更多
干净又极端
4楼-- · 2019-01-07 08:20

Latest Microsoft .NET Framework 4.7 doesn't include C# compiler anymore.

But it can be installed as part of standalone MSBuild tool.

Go to https://www.visualstudio.com/downloads/, scroll down to "Other Tools and Frameworks" and choose "Build Tools for Visual Studio 2017".

After "Visual Studio Build Tools 2017" Online Installer runs, switch to "Individual components" tab and check "C# and Visual Basic Roslyn compilers". This would also check MSBuild dependency. All together less than a hundred of megabytes.

The compiler installs at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\csc.exe.

查看更多
在下西门庆
5楼-- · 2019-01-07 08:25

Yes, there is even an open source one, IDE SharpDevelop. You can set the compiler as a command in UltraEdit (or some other editor of preference), etc.

查看更多
在下西门庆
6楼-- · 2019-01-07 08:27

Assuming you have Visual Studio installed with C# included. Also, assuming you want latest version.

  1. Find the path to your VS installation. Call it VSPath.
  2. The CSC Compiler will be at VSPath\MSBuild(MSBuild-Version)\Bin\Roslyn
查看更多
登录 后发表回答