So I mean compile without visual studio
相关问题
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- Visual Studio 2019 - error MSB8020: The build tool
- 'System.Threading.ThreadAbortException' in
- VS2017 RC - The following error occurred when tryi
相关文章
- How to show location of errors, references to memb
- How to track MongoDB requests from a console appli
- Visual Studio Hangs on Loading UI Library
- How to use Mercurial from Visual Studio 2010?
- Copy different file to output directory for releas
- Edit & Continue doesn't work
- “Csc.exe” exited with code -1073741819
- Visual Studio: Is there an incremental search for
use command line with csc.exe or msbuild
Go to the project directory (I assume .NET framework is in your
PATH
):If you want to compile a bunch of C# source files (not in a project), you'd use the
csc
command.vbc
is VB.NET compiler.jsc
is JScript.NET compiler.cl
is C++/CLI (& plain C++) compiler.There are currently three ways to compile a C# project. The first is with Visual Studio, but you've stated that VS not installed is a constraint. The second is using the raw .NET SDK tools. The third way is to use Mono.
Using msbuild requires Visual Studio to be installed. Using csc does NOT, however it does require the .NET SDK to be installed.
Using .NET:
Compiles File.cs producing File.exe:
csc File.cs
Compiles File.cs producing File.dll:
csc /target:library File.cs
Compiles File.cs and creates My.exe:
csc /out:My.exe File.cs
Compiles all of the C# files in the current directory, with optimizations on and defines the DEBUG symbol. The output is File2.exe:
csc /define:DEBUG /optimize /out:File2.exe *.cs
Using Mono:
Compiles File.cs producing File.exe compat with .NET 1.1:
mcs File.cs
or for .NET 2.0 compatible
Compiles File.cs producing File.dll:
msc /target:library File.cs
Compiles File.cs and creates My.exe:
msc /out:My.exe File.cs
Compiles all of the C# files in the current directory, with optimizations on and defines the DEBUG symbol. The output is File2.exe:
msc /define:DEBUG /optimize /out:File2.exe *.cs
If you already have a solution or project file, use msbuild tool. You can find it deeply inside folder "%windir%\Microsoft.NET\". For example, on my machine I run the following to compile my project:
From here:
Compiles File.cs producing File.exe:
Compiles File.cs producing File.dll:
Compiles File.cs and creates My.exe:
Compiles all the C# files in the current directory, with optimizations on and defines the DEBUG symbol. The output is File2.exe:
I created a batch file that i use for this, so I can compile multiple projects in a row. This should help you get in the right direction: