Answer the question
In order to leave comments, you need to log in
How to make a builder for a Xamarin project?
Hello everyone, here is the builder code for regular .net projects.
private bool compiler(string source, string Output)
{
CompilerParameters CParams = new CompilerParameters();
CParams.GenerateExecutable = true;
CParams.OutputAssembly = Output;
string options = "/optimize+ /platform:x86 /target:winexe /unsafe";
if (puthIco != null)
{
options += " /win32icon:\"" + puthIco + "\"";
}
CParams.CompilerOptions = options;
CParams.TreatWarningsAsErrors = false;
CParams.ReferencedAssemblies.Add("System.dll");
CParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
CParams.ReferencedAssemblies.Add("System.Linq.dll");
CParams.ReferencedAssemblies.Add("System.Security.dll");
CParams.ReferencedAssemblies.Add("System.Xml.dll");
CParams.ReferencedAssemblies.Add("System.Core.dll");
CParams.ReferencedAssemblies.Add("System.Drawing.dll");
CParams.ReferencedAssemblies.Add("System.Data.dll");
CParams.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll");
Dictionary<string, string> ProviderOptions = new Dictionary<string, string>();
ProviderOptions.Add("CompilerVersion", "v4.0");
CompilerResults Results = new CSharpCodeProvider(ProviderOptions).CompileAssemblyFromSource(CParams, source);
if (Results.Errors.Count > 0)
{
MessageBox.Show(string.Format("The compiler has encountered {0} errors",
Results.Errors.Count), "Errors while compiling", MessageBoxButtons.OK,
MessageBoxIcon.Error);
foreach (CompilerError Err in Results.Errors)
{
MessageBox.Show(string.Format("{0}\nLine: {1} - Column: {2}\nFile: {3}", Err.ErrorText,
Err.Line, Err.Column, Err.FileName), "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return false;
}
else
{
return true;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question