Fix ExeGenerator reusability
When re-using ExeGenerator, code wasn't modified because placeholders were gone Now using a copy of the code
This commit is contained in:
@@ -28,18 +28,14 @@ namespace ExeLauncher.GUI
|
|||||||
|
|
||||||
private static string Code { get; }
|
private static string Code { get; }
|
||||||
|
|
||||||
private string _code;
|
|
||||||
|
|
||||||
public ExeGenerator()
|
|
||||||
{
|
|
||||||
_code = Code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompilerErrorCollection CreateExecutable(string location, string paths, string arguments, string workingDirectories, string icon)
|
public CompilerErrorCollection CreateExecutable(string location, string paths, string arguments, string workingDirectories, string icon)
|
||||||
{
|
{
|
||||||
_code = _code.Replace(Paths, paths);
|
// Copy before modifying
|
||||||
_code = _code.Replace(Arguments, arguments);
|
string code = Code;
|
||||||
_code = _code.Replace(WorkingDirectories, workingDirectories);
|
|
||||||
|
code = code.Replace(Paths, paths);
|
||||||
|
code = code.Replace(Arguments, arguments);
|
||||||
|
code = code.Replace(WorkingDirectories, workingDirectories);
|
||||||
|
|
||||||
using (var codeProvider = new CSharpCodeProvider())
|
using (var codeProvider = new CSharpCodeProvider())
|
||||||
{
|
{
|
||||||
@@ -51,7 +47,7 @@ namespace ExeLauncher.GUI
|
|||||||
};
|
};
|
||||||
compilerParameters.ReferencedAssemblies.Add("System.dll");
|
compilerParameters.ReferencedAssemblies.Add("System.dll");
|
||||||
|
|
||||||
var result = codeProvider.CompileAssemblyFromSource(compilerParameters, _code);
|
var result = codeProvider.CompileAssemblyFromSource(compilerParameters, code);
|
||||||
|
|
||||||
if (result.Errors.HasErrors)
|
if (result.Errors.HasErrors)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user