I am new to C# and am trying to use .NET's CodeDom.Compiler to compile an application and properly generate the assembly information in the outputted exe. I've been looking in the MS Docs / Class reference to do so. Is it possible to set the assembly information during compilation?
Code to compile my source code:
CompilerParameters CParams = new CompilerParameters();
CParams.GenerateExecutable = true;
CParams.OutputAssembly = Output;
string options = "/optimize+ /platform:x86 /target:winexe /unsafe";
if (Icon != null)
options += " /win32icon:\"" + Icon + "\"";
CParams.CompilerOptions = options;
CParams.TreatWarningsAsErrors = false;
CParams.ReferencedAssemblies.Add("System.dll");
CParams.ReferencedAssemblies.Add("System.Windows.Forms.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", "v2.0");
CompilerResults Results = new CSharpCodeProvider(ProviderOptions).CompileAssemblyFromSource(CParams, source);
Outputted Exe's Assembly Information:
Is this function available when I'm actually saving the exe using the Writer?
Writer.WriteResource(FSave.FileName, EncryptedBytes);
I greatly appreciate any leads, thank you.
Instead your last line
generate assemblyinfo and add this to source for compilation
msdn