2

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.

9
  • 1
    I didn't try anything yet because after googling i didn't find any guide or tutorial on how can i compile my .cs file using php Commented Jul 11, 2012 at 12:16
  • 3
    Is your web server Windows or Linux? Commented Jul 11, 2012 at 12:16
  • Even in visual studio you can see what command line you must use if you open the "OUTPUT" window Commented Jul 11, 2012 at 12:17
  • Are you trying to compile a single .cs file or will you be providing a full solution? Commented Jul 11, 2012 at 12:17
  • @roken My web server is linux Commented Jul 11, 2012 at 12:18

2 Answers 2

2

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");
Sign up to request clarification or add additional context in comments.

1 Comment

if your distribution allows it, use the mono-csc link instead of calling gmcs directly. That way you'll keep up when mono keeps changing the name of their compiler.
0

This link should help you, using CSC.exe

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

4 Comments

The microsoft compiler isn't designed for linux.
There is nothing in the comments that mentions Linux, apart from your question?
Comment #6, posted before your answer: "@roken My web server is linux – Shikata Ga Nai"
it was posted at the same time, probably when I was searching for the link....pedantic!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.