title | description | author | ms.author | ms.date | ms.topic | ms.localizationpriority | keywords |
---|---|---|---|---|---|---|---|
Using Visual Studio to deploy and debug |
Learn how to build, debug, and deploy apps for HoloLens and Windows Mixed Reality using Visual Studio. |
pbarnettms |
pbarnett |
04/13/2020 |
article |
high |
Visual Studio, HoloLens, Mixed Reality, debug, deploy |
Whether you want to use DirectX or Unity to develop your mixed reality app, you will use Visual Studio for debugging and deploying. In this section, you will learn how to:
- Deploy applications to your HoloLens or Windows Mixed Reality immersive headset through Visual Studio.
- Use the HoloLens emulator built in to Visual Studio.
- Debug mixed reality apps.
- See Install the Tools for installation instructions.
- Create a new Universal Windows app project in Visual Studio. For HoloLens (1st gen), use Visual Studio 2017 or newer. For Hololens 2, use Visual Studio 2019 16.2 or newer. C# and C++ are supported. (Or follow the instructions to create an app in Unity.)
Start by enabling Developer Mode on your device, so Visual Studio can connect to it.
- Turn on your HoloLens and put on the device.
- Perform the start gesture to launch the main menu.
- Select the Settings tile to launch the app in your environment.
- Select the Update menu item.
- Select the For developers menu item.
- Enable Developer Mode. This will allow you to deploy apps from Visual Studio to your HoloLens.
- Optional: Scroll down and also enable Device Portal. This will also allow you to connect to the Windows Device Portal on your HoloLens from a web browser.
If you are working with a Windows Mixed Reality headset connected to your PC, you must enable Developer Mode on the PC.
- Go to Settings
- Select Update and Security
- Select For developers
- Enable Developer Mode, read the disclaimer for the setting you chose, then click Yes to accept the change.
- Select an x86 build configuration for your app
- Select Remote Machine in the deployment target drop-down menu
- For C++ and JavaScript projects, go to Project > Properties > Configuration Properties > Debugging. For C# projects, a dialog will automatically appear to configure your connection.
a. Enter the IP address of your device in the Address or Machine Name field. Find the IP address on your HoloLens under Settings > Network & Internet > Advanced Options, or you can ask Cortana "What is my IP address?"
b. Set Authentication Mode to Universal (Unencrypted protocol)
- Select Debug > Start debugging to deploy your app and start debugging
- The first time you deploy an app to your HoloLens from your PC, you will be prompted for a PIN. Follow the Pairing your device instructions below.
- Select an ARM or ARM64 build configuration for your app
- Select Remote Machine in the deployment target drop-down menu
- For C++ and JavaScript projects, go to Project > Properties > Configuration Properties > Debugging. For C# projects, a dialog will automatically appear to configure your connection.
a. Enter the IP address of your device in the Address or Machine Name field. Find the IP address on your HoloLens under Settings > Network & Internet > Advanced Options, or you can ask Cortana "What is my IP address?"
b. Set the Authentication Mode to Universal (Unencrypted protocol)
- Select Debug > Start debugging to deploy your app and start debugging
- The first time you deploy an app to your HoloLens from your PC, you will be prompted for a PIN. Follow the Pairing your device instructions below.
If your HoloLens IP address changes, you can change the IP address of the target machine by going to Project > Properties > Configuration Properties > Debugging
- Select an x86 build configuration for your app
- Select Device in the deployment target drop-down menu
- Select Debug > Start debugging to deploy your app and start debugging
- The first time you deploy an app to your HoloLens from your PC, you will be prompted for a PIN. Follow the Pairing your device instructions below.
- Select an ARM or ARM64 build configuration for your app
- Select Device in the deployment target drop-down menu
- Select Debug > Start debugging to deploy your app and start debugging
- The first time you deploy an app to your HoloLens from your PC, you will be prompted for a PIN. Follow the Pairing your device instructions below.
Follow these instructions when using a Windows Mixed Reality immersive headset that connects to your PC or the Mixed Reality simulator. In these cases, simply deploy and run your app on the local PC.
- Select an x86 or x64 build configuration for your app
- Select Local Machine in the deployment target drop-down menu
- Select Debug > Start debugging to deploy your app and start debugging
The first time you deploy an app from Visual Studio to your HoloLens, you will be prompted for a PIN. On the HoloLens, generate a PIN by launching the Settings app, go to Update > For Developers and tap on Pair. A PIN will be displayed on your HoloLens; type this PIN in Visual Studio. After pairing is complete, tap Done on your HoloLens to dismiss the dialog. This PC is now paired with the HoloLens and you will be able to deploy apps automatically. Repeat these steps for every subsequent PC that is used to deploy apps to your HoloLens.
To un-pair your HoloLens from all computers it was paired with, launch the Settings app, go to Update > For Developers and tap on Clear.
- Make sure you have installed the HoloLens Emulator.
- Select an x86 build configuration for your app.
- Select HoloLens Emulator in the deployment target drop-down menu
- Select Debug > Start debugging to deploy your app and start debugging
- Make sure you have installed the HoloLens Emulator.
- Select an x86 or x64 build configuration for your app.
- Select HoloLens 2 Emulator in the deployment target drop-down menu
- Select Debug > Start debugging to deploy your app and start debugging
The Visual Studio Graphics Diagnostics tools are very helpful when writing and optimizing a Holographic app. See Visual Studio Graphics Diagnostics on MSDN for full details.
To Start the Graphics Debugger
- Follow the instructions above to target a device or emulator
- Go to Debug > Graphics > Start Diagnostics
- The first time you do this with a HoloLens, you may get an "access denied" error. Reboot your HoloLens to allow updated permissions to take effect and try again.
The Visual Studio profiling tools allow you to analyze your app's performance and resource use. This includes tools to optimize CPU, memory, graphics, and network use. See Run diagnostic tools without debugging on MSDN for full details.
To Start the Profiling Tools with HoloLens
- Follow the instructions above to target a device or emulator
- Go to Debug > Start Diagnostic Tools Without Debugging...
- Select the tools you want to use
- Click Start
- The first time you do this with a HoloLens, you may get an "access denied" error. Reboot your HoloLens to allow updated permissions to take effect and try again.
You can use Visual Studio to debug a Universal Windows app that's installed without deploying from a Visual Studio project. This is useful if you want to debug an installed app package, or if you want to debug an app that's already running.
- Go to Debug -> Other Debug Targets -> Debug Installed App Package
- Select the Remote Machine target for HoloLens or Local Machine for immersive headsets.
- Enter your device’s IP address
- Choose the Universal Authentication Mode
- The window shows both running and inactive apps. Pick the one what you’d like to debug.
- Choose the type of code to debug (Managed, Native, Mixed)
- Click Attach or Start
If you're following the Unity development checkpoint journey we've laid out, you're in the midst of the deployment stage. From here, you can proceed to the next topic:
[!div class="nextstepaction"] Deploying to HoloLens emulator
Or jump directly to adding advanced services:
[!div class="nextstepaction"] Advanced services
You can always go back to the Unity development checkpoints at any time.