Rafik Bari
Rafik Bari

Reputation: 5037

How to compile a .NET source file into executable using PHP?

Using C#.NET, i wrote a toolbar which is stored now into toolbar.cs file.

I want to upload this file to my FTP server with another php file say : compiler.php

i want to be able to compile the toolbar.cs file when i access to

http://www.mysite.com/toolbar.php

Then a new file is created in the same directory containing the ready to download executable.

The reason why i'm trying to do that, is to create a website that create custom toolbars with personalized features for my users.

Upvotes: 2

Views: 1284

Answers (2)

roken
roken

Reputation: 3994

I'm fairly certain no one has written a C# compiler in PHP, so you're going to have to call a compiler via a command line call from your php code.

On Linux, you'll be using the Mono compiler: http://mono-project.com/CSharp_Compiler

Something along these lines (dependent upon the location of toolbar.cs, your required references, and .NET version to target):

exec("gmcs -pkg:dotnet toolbar.cs");

Upvotes: 2

Christian Phillips
Christian Phillips

Reputation: 18759

This link should help you, using CSC.exe

http://msdn.microsoft.com/en-us/library/78f4aasd.aspx

Upvotes: 0

Related Questions