Visual Studio 2010 Creating an Application That Compiles Code

I want to be able to compile code from another application that I created.

Long story:

I am working on creating a 2D engine from scratch using the SDL (no comments on which is better to use). I understand how to use the SDL libraries and create simple games. Nevertheless, I want to strive for larger projects, but I need to create an application that will help me organize the code and the overall system. In principle, this program should be an editor (like Unity or UDK, but not as advanced, of course). Programming a real application using a code editor, etc. Not difficult, but my question is how can I take this code and compile it, run it and / or export it as an exe? (Taking code and scripts and putting them into the architecture for compilation is not a problem, it is knowing how to compile its idea).

This is a new idea for me, and googling did not give me the results that I wanted, so I decided to come to StackOverflow because I had a lot of questions that were asked here before, without having to ask (you guys are great by the way).

TL DR Version:

Compile the code from another native application.

(My idea is to use C # for the interface or gui, and then C / C ++ for the real engine)

+4
source share
4 answers

My answer is based on what I will do (at least for the development period): Use existing components. Namely, the editor and script compiler;

For your editor you can use Avalon Edit

For your compilation / script you must use CS-Script

You can work and work for 4-5 hours with them, and you can use entity scripts with the option of "hot" replacement with little work.

Just use a basic exe that can read the root script file for the project and run it.

Damn, I bet you can even grab the assembly that CS-Script does in memory and save it for later use.

If you go through the "Create-New-Engine-Reduction" stage, you can come back and support other languages.

+1
source

If you are talking about creating a visual editing environment such as Unity - something that can host visualized visual effects, the user interface handles game engine variables, audio editing, and editing and compiling these scripts scripts, then you will need to use that- something like MSBuild.

Since you are claiming that you have the packaging and management of project files under control, and assuming that you intend to create this customizable interface to make changes to the files referenced by the visual studio solution, then all you have to do is call MSBuild with the appropriate command line arguments.

see MSBuild (MSDN)

0
source

If you talk more about the editing side, then perhaps Visual Studio Shell: Wikipedia says the following:

Visual Studio 2008 introduced the Visual Studio shell, which allows you to develop an individual version of the IDE. Visual Studio Shell defines a set of VSPackages that provide the functionality required in any IDE. In addition, you can add other packages to configure the installation. Shell isolated mode creates a new AppId in which packages are installed. They should be launched with another executable file. It is designed to develop custom development environments, both for a specific language and for a specific scenario. Integrated mode installs packages into the AppId from the Professional / Standard / Team System editions, so the tools are integrated into these editions. [16] Visual Studio is available as a free download.

You can force this shell to use any compiler (s) ... a lot of work.

0
source

You can see the following:

var csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } }); var parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, "foo.exe", true); parameters.GenerateExecutable = true; CompilerResults results = csc.CompileAssemblyFromSource(parameters, @"using System.Linq; class Program { public static void Main(string[] args) { var q = from i in Enumerable.Rnge(1,100) where i % 2 == 0 select i; } }"); results.Errors.Cast<CompilerError>().ToList().ForEach(error => Console.WriteLine(error.ErrorText)); 

This code will compile the code in the results variable and output it to foo.exe .

0
source

All Articles