The Build
method in the Sandbox.Compiler
class is responsible for building and loading the assembly from the provided C# source files. This method compiles the source code into an assembly that can be executed within the s&box environment.
The Build
method in the Sandbox.Compiler
class is responsible for building and loading the assembly from the provided C# source files. This method compiles the source code into an assembly that can be executed within the s&box environment.
To use the Build
method, ensure that you have set up the Sandbox.Compiler
instance with the necessary source paths and configuration. Once the setup is complete, invoke the Build
method to compile the source files into an assembly.
// Example of using the Build method // Create a new instance of the Compiler var compiler = new Compiler(); // Add source paths compiler.AddSourcePath("path/to/source/files"); // Optionally set configuration var config = new Compiler.Configuration(); compiler.SetConfiguration(config); // Build the assembly compiler.Build(); // Check if the build was successful if (compiler.BuildSuccess) { // The assembly was built and loaded successfully Console.WriteLine("Build succeeded."); } else { // Handle build errors foreach (var diagnostic in compiler.Diagnostics) { Console.WriteLine(diagnostic.ToString()); } }