How to create two different executables from one Visual Studio project
You can build as many assemblies in one solution as you like. Assemblies can result in DLL files or EXE files.
Create a solution (or open an existing solution).
Right-click the root node in Solution Explorer and choose Add → New Project and choose the project type you like to add.
Right-click the project item in Solution Explorer and choose Properties → Build → Output path. Set to the desired directory where to build it to. Repeat this for the other projects.
This way you get the following in Solution Explorer:
- MySolution
- MyCommonCode (Class Library, results in MyCommonCode.dll)
- MyMainApp (Windows Forms application, results in MyMainApp.exe)
- MyConfigApp (Windows Forms application, results in MyConfigApp.exe)
The MyCommonCode assembly contains shared code that both EXE files are using like the identifiers of your configuration file, etc.
MyMainApp is the GUI application (Windows Forms, WPF, etc.) for your main application with a project-reference to the MyComonCode project.
MyConfigApp is a GUI application for editing the configuration values with a project reference to MyCommonCode project.
After building your solution you get the following binaries: MyCommonCode.dll
, MyMainApp.exe
, and MyConfigApp.exe
.
Update based on the comment:
One compile-run can build only one binary (DLL or EXE) per project. You can do something like the answer above: move most of the code in a common/core DLL and make two thin projects for the two EXE files which only "configure and use" the central common/core DLL file.
You can build different EXE files based on the same project using compiler defines. You can even define your own defines. But per compile-run you can only build one binary (DLL, EXE) per project - one or the other, but not both.