Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile a C# project without MSBuild?

Tags:

c#

msbuild

I am working on a deployer application that publishes (builds and creates the output) of C# projects and does other works.

MSBuild is not handy. So, I thought about creating my own build engine.

I know it's possible to use C# compiler to compile a simple sample.cs file into a dll file. But can I compile a project entirely without MSBuild?

like image 752
Armin Binevli Avatar asked Nov 09 '15 12:11

Armin Binevli


2 Answers

Yes, you can use csc (the C# compiler) all the way to compile your source code. The problem is you have to everything yourself.

Since MSBuild can interpret sln and csproj files, and understands the various actions to be taken, the references to use and where to find them, it is much easier to use than csc. For example: there are some Tasks specific for Office add-ins. MSBuild knows how to execute them from their remote target files. You don't, so if you want to use those, you need to do all actions yourself. It is possible, just a little hard if you want to compile very complex projects.

It might help to use Roslyn to set up your compile statements and actually compile your code. You still need a way to specify all parameters.

like image 138
Patrick Hofman Avatar answered Sep 28 '22 07:09

Patrick Hofman


As it's mentioned in this answer, you can use other build engines to see if they fit your needs or not. Two of them are Microsoft.Build, and Make for Windows

like image 39
Nasseh Avatar answered Sep 28 '22 08:09

Nasseh