Reputation: 21
I have a requirement to build a container C# WinForm Application which will spit out .exe files of another WinForm Application on a button click event.
For eg: I have one Winform App named ProjectA which accepts one startup argument. Now I have a container WinForm App named ProjectB. I want to generate ProjectA.exe programmatically within ProjectB by passing the required parameter to ProjectA app on the button click.
Could not find anything relevant about this on Google. Can anyone throw in some light to achieve this.
Please note that both the Winforms Application must be written in C#.
I have one very vague thought of using MSBuild Command to build ProjectA which in turn will generate its .exe However I am not too clear on this.
Upvotes: 1
Views: 253
Reputation: 1897
As an example:
Process.Start(@"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe", @"d:\app1\app1.sln");
Another Example:
Process.Start(@"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe", @"d:\app1\app1.sln /t:Rebuild /p:Configuration=Debug;TargetFrameworkVersion=v4.0");
put the above code on your button click.
Upvotes: 0
Reputation: 1317
It is not necessary to mess with MSBuild for this. You may generate your program's code as a string and then generate your executables on the fly:
Upvotes: 0