Automatically set a startup project for Windows Universal Apps
Now with Universal Apps we have 3 or more projects loaded into the Visual Studio solution.
- Windows 8.1 Project: It contains XAML UI pages and code that targets Windows 8.1.
- Windows Phone 8.1 Project: It contains XAML UI pages and code that targets Windows Phone 8.1.
- Shared Project : It contains have XAML UI pages and code that are common to both platforms.
The following screenshot illustrates:
As you can notice in the previous screenshot there is one project name that stands out with Bold marking. That is the Startup project, which is the project that runs when you run the solution - for example by pressing F5. Visual Studio runs the project that is selected as the startup. Now, in order to set the startup project, we need to right-click on a specific project node in Solution Explorer and choose Set as Startup Project. The project that we now chose will show in bold in Solution Explorer as a visual aid. In the previous screenshot, it was Site2App3 (Windows 8.1)
So if we run the project now, the Windows App will deploy and start. Moreover, if we need to run the Windows Phone app, we will need to need to set it as Startup up by right-clicking on the Windows Phone 8.1 project node in Solution Explorer and choosing Set as Startup Project. It gets a bit mundane if you keep doing this for sometime while alternating between projects to run the apps after every modification.
Well, I have the answer. The solution to make your lives easier. We can do something in Visual Studio that allows us to run the project without worrying about setting a Startup Project and let Visual Studio decide depending on the current selection, whereby, whatever project you highlight in the Solution Explorer (or file you select in the text editor) will in turn become the current startup project.
To achieve this, right-click on the solution explorer, choose properties. Next select Startup Project, from there select Current Selection from the Radio Button List. The following screenshot illustrates:
**By the way this (multiple projects in a single solution) is not the Y2K problem, developers faced similar situations in the past where they had a website project alongside a console application or windows service or others.**
Happy Coding :)