This source code demonstrates how to publish an app using ClickOnce with multiple environments profile and install both apps in computer at the same time.
Create new profile Dev
which is a copy of Debug
and Prod
which is a copy of Release
. This is only done for demo purpose. This can be used by Debug
or Release
configurations as well. Helpful, in cases where different behaviour is needed for different build configurations. Otherwise,
In order to display different console message when both apps are run set conditional symbol DEV
for Dev
build configuration. This step is optional and only needed to test if the app you are running is running with Dev profile or from Prod profile.
After this you can use it in Program.cs
#if DEV
Console.WriteLine("Hello, World! (Dev)");
#else
Console.WriteLine("Hello, World! (Prod)");
#endif
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
If using Debug
and Release
configurations then .csproj
file should be edited accordingly.
In this demo we will publish the exe on our local machine in different folders for Dev
and Prod
.
- Set the Auto increment of versions and set
Publisher name
andProduct name
to differentiate betweenDev
andProd
app during installation and in Control panel.
Follow, same steps with Prod
profile.
- Once the profiles are set Publish both apps in
Publish Wizard
. After publish both exe will be available in their respective folders.
When the apps are intalled we see two different apps in the Control Panel
for Dev
and Prod
. This allows us to run the apps simultaneously without overriding / uninstalling the other.
After running the apps it displays message based on the app.