The other day I was doing a live stream with Luce Carter. While doing so I actually learned a thing myself about debugging multiple projects at the same time. You can very easily set this up in Visual Studio for Mac with run configurations. I decided to write it up so you can benefit as well!
Video edition of this blog can be found underneath. Don’t forget to subscribe :)
What are we doing? #
So, if you’re working on Xamarin.Forms applications, you are probably working on at least two simultaneous target platforms. Or, another scenario might be where you have a REST API and an app and you need to run both of them to test things.
Before, you might have started two instances of Visual Studio or you would stop the first debug run and then proceed with the next. But, as it turns out, this is not needed! You can run and debug multiple projects with the press of ONE play button.
How to use run configurations #
Open Visual Studio for Mac and open the solution that has the projects you want to debug.
In the Solution Explorer, right-click your solution, in this case “PancakeFinder”, indicated by the 1 in the screenshot below. From there go to 2: click Options. And in the screen that comes up, click 3 Configurations.
Create run configurations in Visual Studio for Mac
In this window you can manage your run configurations. In the screen above I have already created one named AndroidAndiOS.
Right after publishing this blog, I got a tweet saying that since a version or two, this screen can also be reached from the “Set Startup Projects…” option that was staring me right in the face in the screenshot above. Thanks for letting me know Sayed!
FYI a couple releases ago we simplified this by adding a solution context menu option "Set Startup Projects". It's just an easier way to acheive the same result. pic.twitter.com/RxbemZTVjD— Sayed I. Hashimi 🇺🇦 (@sayedihashimi) May 26, 2020
You can easily add a new run configuration by clicking the New button near the button. Give it a descriptive name, confirm and it shows up in the dropdown on the left.
If you go into one of the run configurations, you can see all the (runnable) projects in your solution. Simply check the ones that you want to start simultaneously and click OK. You can see this in the screenshot below.
Configure your run configuration by clicking the projects you want to run
Run and debug your projects #
Time to run the actual configuration. In the dropdown at the top, you will now have the run configuration available as you can see in the screenshot below.
Select it and notice how the last dropdown option now changes to Multiple. If you click that, you can select, per project in this run configuration, which emulator or browser or other thing to use. This depends on the type of project. In the screenshot below you can see an example where I choose a Simulator for my iOS project.
Select specific run options for a project within the run configurations
Now, simply press F5 or push the run button and all selected projects will come at you at the same time.
In closing #
In this post we have learned how to setup run configurations in Visual Studio for Mac. This is a very simple but powerful option. With this you can easily run both your iOS and Android apps at the same time, or maybe your iOS and REST API backend project.
The functionality is pretty similar to multiple startup projects on Visual Studio on Windows.
Thank you again Luce for teaching me this! I hope it will benefit some others now as well. The live stream can be found here. While you’re there, please subscribe to my YouTube channel.