ironpython3
ironpython3 copied to clipboard
Let IronPython Compiler only create one exe file when target to exe or winexe
The issue is #1785
I add a new method CreateAssemblyGen in ClrModule to get AssemblyGen, so that I can add exe host code into ScriptCode assembly. Then I change the init code from
string currentDirectory = Environment.CurrentDirectory;
Environment.CurrentDirectory = new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName;
string fullPath = Path.GetFullPath("bin/Program.dll");
Environment.CurrentDirectory = currentDirectory;
return PythonOps.InitializeModuleEx(Assembly.LoadFile(fullPath), "__main__", null, ignoreEnvVars: false, null);
to
return PythonOps.InitializeModuleEx(Assembly.GetExecutingAssembly(), "__main__", null, ignoreEnvVars: false, null);
since the ScriptCode assembly is itself.
But now it have some new problem. Since the AssemblyBuilder dose not have DefineIconResource method, I have no ideal to add win32 icon. And the Windows Defender said it is viruses when /standalone option is on...
PS. I use reflection to invoke SavableScriptCode.CompileForSave since SavableScriptCode is in DLR repository. It is better to add CreateAssemblyGen method for SavableScriptCode.
Looks fine with .NET Core App