Q:

How to avoid running the application when a ClickOnce installation completes?

I want setup.exe to do only the setup (seems like a natural thing to ask for), so that the user can later choose to run the application themselves. I tried "Block application from being activated via a URL" in publish options in Visual Studio, but that did not seem to work. There is also a specific option in MageUI to avoid running the application, but that also did not seem to work.

A:

If you want to use the setup.exe file that Visual Studio generates for you, I don't think there's any way to stop it from launching your app. Most people want it to launch. I suppose in your application code you could try to detect when it was run for the first time and simply kill it, but that seems pretty flaky to me.
You don't have to even use the setup.exe that VS generates. How many prerequisites do you have? It's very handy when you have a lot of prereqs, but if you just need the .NET Framework, you could skip the generated bootstrapper and just give them a link to the download.
Couple more notes. The "Block application from being activated via a URL" won't work for you. This just means that the user has to use the start menu shortcut to run the app rather than typing the url in a browser. Also, I'm not completely sure, but I think the MageUI option only works if you install your app for the first time from a browser and not the bootstrapper. Could be wrong on that one though.
Edit
I randomly stumbled across this answer, Install ClickOnce Without Running. The accepted answer shows a quick and easy implementation of my first suggestion - quitting the app if it's the first time it has been run.

