microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Deploying to device is cumbersome and not available directly from Unity #49

Closed jwittner closed 8 years ago

jwittner commented 8 years ago

I'd like to add a sub menu to the HoloToolkit Unity menu that allows a single operation for building and deploying to device or the emulator.

I'm thinking something like:

Here's the process I see:

  1. WSA Build from Unity
  2. Nuget restore of VS Solution
  3. MSBuild build of VS Solution
  4. WinAppDeployCmd of appx.

I'd prefer a solution that only required visual studio, but I'm running into these issues:

  1. VS cmd line /build doesn't do the nuget restore (the documentation says it does exactly what Build Solution does, but that's a lie).
  2. VS cmd line /build doesn't generate a deployable appx, just binaries.
  3. VS cmd line /deploy doesn't let me set the deployment target. (There is no documentation I can find for controlling the target via the command line).
alexdrenea commented 8 years ago

Maybe we could use msbuild.exe to build the app and the packages. I've been playing a bit with this and was able to generate an apppackage but could not deploy to device using WinAppDeployCmd. If you're still looking into this, maybe we can collaborate and make this happen.

jwittner commented 8 years ago

Yeah, I was intending to use MSBuild and WinAppDeployCmd because build/deploy with VS Command line seems nigh impossible. #52 is a partial step to solving this issue as it introduces tooling for simplifying the VS Sln output from within Unity.

I haven't made any progress past #52 and would love some help pushing this forward.

alexdrenea commented 8 years ago

In my tests I've gotten as far as doing the WSA build from unity and getting all the commands right to build the appxbundle. What would be the best way to share that code with you? Not sure I can / should commit on your fork.

NeerajW commented 8 years ago

@alexdrenea please do that as a separate pull :)

jwittner commented 8 years ago

Alternatively, we can run with your fork/branch as the core dev spot for this, and if I can help I can make pull requests to that. Then when we're done you can do a pull from yours to here. Does that make sense?

alexdrenea commented 8 years ago

Sorry for the delay guys, I just pushed my progress so far in a branch in my fork. It's not functional yet so I didn't want to put a pull request in. I will not be able to make much progress in the next 2-3 weeks due to other commitments so at least you can see what I've got so far in my fork.

jwittner commented 8 years ago

@alexdrenea Just checked out your branch, looks like a good starting place. I'll probably get a chance to put some time into this in the next couple weeks. I'll merge your branch in and start from there.

alexdrenea commented 8 years ago

are you able to merge it or you need a PR?

jwittner commented 8 years ago

I should be able to merge it into my local branch. I'll reach out if I have any problems. Thanks!

jwittner commented 8 years ago

@alexdrenea Made some progress integrating your code into the build menu here: https://github.com/jwittner/HoloToolkit-Unity/tree/dev/buildMenu. Still not ready for a PR, but we're getting closer.

I get an error from WinAppDeployCmd that might indicate it won't work for the HoloLens. Maybe someone on here knows if it does or can help find a way to push an appxbundle to the device via the command line.

I get this output from WinAppDeployCmd:

Windows App Deployment Tool
Version 10.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

Opening connection to device at '<redacted>'.
Checking remote system architecture...
Disconnecting.

0x80131500 - Exception from HRESULT: 0x801C000B
0x801C000B - Exception from HRESULT: 0x801C000B
riverar commented 8 years ago

It seems WinAppDeployCmd/Sirep in the Windows 10 SDK (10.0.10586) is busted. (I couldn't even get past PIN auth, you seem to have gotten further.) Later versions of the SDK (e.g. 14366) seem to work fine, will take a deeper look and see what changed.

@jwittner I presume you're using a HoloLens that is running the latest build of Windows on it?

jwittner commented 8 years ago

@riverar I thought I was cause we just got the kits in recently, but it looks like someone flashed it to a test build. I'm going to reset it now, will test again tonight, and let you know the outcome.

And thanks so much for looking into this with me!

jwittner commented 8 years ago

@riverar On latest I don't see this issue, but I can't figure out how to get authenticated now. I'm going to the developer settings and getting a pin via the Pair Device window, but that doesn't seem to generate a viable pin as I still get rejected. Hoping you can help, but perhaps I'm at the same level you are now?

riverar commented 8 years ago

@jwittner I'm going to power on a HoloLens that hasn't been updated to see this scenario ever worked.

I suspect HoloLen's sirep implementation is not compatible with 10586 SDK. Newer versions of the SDK alleviate this issue but aren't final so can't be recommended to end-users in good faith. Quite the pickle!

One quick workaround might be to just document that users must enable the Device Portal and hit the appx deployment endpoint (/api/app/packagemanager/package) via a PowerShell script.

Will share more as I dig deeper!

jwittner commented 8 years ago

@riverar Ok, thanks for all your help! I like your PowerShell work around and I'll pursue that in the interim!

Out of curiosity can you point me to what you mean by sirep? A quick search hasn't offered me much useful.

stbertou commented 8 years ago

Hi all, first a quick intro, I've just started in the MCS hololens studio here in London. I have a lot of questions should I create an issue here for each one (they're technically not issues but more questions.. unless there's a forum somewhere I could use instead?)

Regarding this "deploying to device.." issue, what about having a proper Hololens platform straight in the BuildSettings popup next to Windows, Xbox etc.. Would that be possible ?

alexdrenea commented 8 years ago

Hi Stephane. I'm not sure that a new platform is a viable option, since the HoloLens target is in fact just a Windows 10 regular solution that you can run either holographically or not.

jwittner commented 8 years ago

Hey Stephane! I'm on the MCS HoloLens US team, welcome to the org!

I tried to find a way to modify the build screen in Unity before I went with the build menu, but couldn't find any way to do it. Right now the "Build for HoloLens" menu option is simply performing the same kind of build you'd get from the menu, but ensures all the settings are configured correctly.

stbertou commented 8 years ago

@alexdrenea makes sense but then what about a Hololens toggle option on the WindowsStore PlayerSettings tab? unless that's more something for the Unity folks?

@jwittner what you propose would be already very useful ! Found this link (but you probably found it already!) http://blogs.unity3d.com/2014/10/02/in-the-labs-custom-build-configurations/

alexdrenea commented 8 years ago

I guess that what I'm confused about is what would that toggle do? What would I get out of an "HoloLens" type project when I built it ? I guess it could be as simple as just generating a Solution that is more "suited" to HoloLens (update some of the PlayerSettings to ensure it uses Holographic, generate x86 only architectures.

stbertou commented 8 years ago

Exactly ! The fact you have to edit the manifest manually for example is annoying. Don't get me wrong it's already really nice and easy (and before joining MS I had no idea HL dev was already that mature) but I guess it could be even better. It will probably come at some point as well but having a way to directly build and send an app to the device straight from Unity would be really useful. There must be a way to open a specific VS solution in no UI mode or something and force a 'Start without Debugging' process no? When I work on iOS or Android from Unity, I always use the "Build and Run" option. It just makes you more efficient by removing some extra steps.

jwittner commented 8 years ago

The Configure section in the HoloToolkit menu has options for configuring both the Project and the current Scene with all of the recommended HoloLens settings. Once you've done that, the "Build for HoloLens" option in the Build section will output the Visual Studio solution with all of the recommended build settings configured correctly. I'll open up an issue to get both of those documented sooner rather than later, but if you go to the configure section and "Show Help" it'll open up the online docs for configuring Unity - this outlines what the configuration options do to your project or scene respectively.

@stbertou The proposed solution to this issue is to add a "Deploy to HoloLens" button which will do everything necessary to end with an executable build on the HoloLens. That's what I'm currently focused on here. See the initial description for the proposed process for doing that with notes on why Visual Studio is being bypassed.

Can I ask what parts of the manifest you are editing manually?

stbertou commented 8 years ago

So far I only had to replace the name field for TargetDeviceFamily to be Windows.Holographic And guess this could be set automatically

alexdrenea commented 8 years ago

Interesting question, not sure about that. I checked my projects and they are indeed set up as Windows.Universal not Holographic. Any reason you'd want it Holographic and not Universal? Just to ensure it cannot be available on a regular device?

stbertou commented 8 years ago

I have no idea why it has to be set as Windows.Holographic. I've just followed a tutorial where that was explained. Could that be this tutorial is outdated and it's actually not required anymore !?

alexdrenea commented 8 years ago

Might be outdated. All you need to do is ensure that in Unity - Player Settings - Other Settings, you have Virtual Reality Supported enabled and Windows Holographic is set as the SDK. There's a thread on the hololens forums about that: https://forums.hololens.com/discussion/322/why-is-my-app-always-deploying-in-2d-mode. Hope it helps.

jwittner commented 8 years ago

Alternatively, add the HoloToolkit-Unity to your project, then HoloToolkit->Configure->Apply Project Settings. That'll do everything necessary and recommended, including the Virtual Reality setting in the Player Settings.

riverar commented 8 years ago

@jwittner I'm an external so can't provide any authoritative info. But I believe sirep stands for "Simple Remote Procedures". In the context of HoloLens, the transport used is standard SSH. It uses a slightly customized authentication method (which you can observe by attempting to SSH into the headset w/ a username of DevToolsUser.)

The 10.0.10586 tooling doesn't seem to have been updated with this authentication method so WinAppDeployCmd is out for now.

Here's a PowerShell script I put together to deploy packages from the cli. Preliminary but works. Was pulling my hair out for a short bit when I ran into Device Portal bugs -- that package manager API is certainly wonky.

https://gist.github.com/riverar/4046c3f97582e63dca618ab7f99cd337

stbertou commented 8 years ago

perfect ! thanks for the help guys ! (maybe those tutorials should be updated then)

jwittner commented 8 years ago

@riverar Thanks for the script! I should get some time tomorrow to try and plum it into my branch. I've reached out internally for information on HoloLens and support for WinAppDeployCmd.

riverar commented 8 years ago

@jwittner Anything you can share would be great

jwittner commented 8 years ago

Sounds like the Web Portal is the preferred method going forward across all device types. A member of another team at Microsoft has a nice Build Window pretty far along (believes he's just a couple days out from a PR) that accomplishes nearly everything we're talking about here that he's planning to contribute. I'm encouraging him to get involved here and am going to postpone my own development in lieu of that work.

riverar commented 8 years ago

@jwittner OK, hope they see/fix my reported bugs!

jwittner commented 8 years ago

Resolved by #87.