How to compile a C # project from source

So, I mean compilation without visual studio

+7
compiler-construction visual-studio
source share
7 answers

From here :

Compiles the File.cs file that creates File.exe:

csc File.cs 

Compiles the File.cs file that creates the File.dll file:

 csc /target:library File.cs 

Compiles File.cs and creates My.exe:

 csc /out:My.exe File.cs 

Compiles all C # files in the current directory with optimization and defines the DEBUG symbol. The output file is File2.exe:

 csc /define:DEBUG /optimize /out:File2.exe *.cs 
+13
source share

Change to the project directory (I assume the .NET framework is in your PATH ):

 msbuild <enter> 

If you want to compile a bunch of C # source files (not in the project), you should use the csc command. vbc is the VB.NET compiler. jsc is a JScript.NET compiler. cl is a C ++ / CLI compiler (& plain C ++).

+9
source share

If you already have a solution or project file, use the msbuild tool. You can find it deep inside the folder "% windir% \ Microsoft.NET \". For example, on my machine, I ran the following command to compile my project:

 C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe MassiveMultithreading.sln 
+4
source share

I created a batch file that I use for this, so I can compile several projects in a row. This should help you in the right direction:

 cls echo off c: cd windows cd microsoft.net cd framework cd v3.5 msbuild c:\Project\Project.sln /t:rebuild /p:Configuration=Debug /p:Platform="any cpu" /clp:Nosummary 
+3
source share

use command line with csc.exe or msbuild

0
source share

Set your path or change the directory to C: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 (note if the directory is used when using a different version of the framework).

Type of:

MSBuild / path / to / your / project / projectname.solution / rebuild

Or using csc from the command line. Again, go to the directory mentioned above, this time the command

csc / out: filename.exe / path / to / your / project / *. cs

Note. CSC.exe has several hundred operations. Enter csc -help for more details.

0
source share

There are currently three ways to compile a C # project. The first one is with Visual Studio, but you stated that VS is not installed - this is a limitation. The second uses raw .NET SDK tools. The third way is to use Mono .

Using msbuild requires installing Visual Studio. Using csc is NOT, however, this requires the installation of the .NET SDK.

Using .NET:

  • Compiles the File.cs file that creates File.exe:

    csc File.cs

  • Compiles the File.cs file that creates File.dll:

    csc /target:library File.cs

  • Compiles File.cs and creates My.exe:

    csc /out:My.exe File.cs

  • Compiles all C # files in the current directory with optimization and defines the DEBUG symbol. The output file is File2.exe:

    csc /define:DEBUG /optimize /out:File2.exe *.cs

Using mono:

  • Compiles File.cs, creating File.exe compatible with .NET 1.1:

    mcs File.cs

or for compatibility with .NET 2.0

 gmcs File.cs 
  • Compiles the File.cs file that creates File.dll:

    msc /target:library File.cs

  • Compiles File.cs and creates My.exe:

    msc /out:My.exe File.cs

  • Compiles all C # files in the current directory with optimization and defines the DEBUG symbol. The output file is File2.exe:

    msc /define:DEBUG /optimize /out:File2.exe *.cs

0
source share

All Articles