using Microsoft.CodeAnalysis;using Microsoft.CodeAnalysis.CSharp;using System;using System.IO;class Program{ static void Main() { string code = @" using System; class HelloWorld { static void Main() { Console.WriteLine(""Hello, World!""); } } "; SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code); string outputFilePath = "HelloWorld.exe"; var compilation = CSharpCompilation.Create( Path.GetFileNameWithoutExtension(outputFilePath), new[] { syntaxTree }, new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) }, new CSharpCompilationOptions(OutputKind.ConsoleApplication)); var result = compilation.Emit(outputFilePath); if (result.Success) { Console.WriteLine("Compilation successful. Output file: " + outputFilePath); } else { Console.WriteLine("Compilation failed. Errors:"); foreach (var diagnostic in result.Diagnostics) { Console.WriteLine(diagnostic.ToString()); } } }}