MixedRealityToolkit-Unity: DirectoryNotFoundException - Issues with MSBuild integration

Describe the bug

When setting up a new MRTK project, either by adding MRTK to the project, or simply opening Unity have a fresh clone, letting the MRTK editor window configure my project introduces MSBuild, which will often lead to a flurry of exceptions, which prevent building on any platform, including UWP and Android.

To reproduce

My repro steps aren’t 100% reliable, but what often triggers it for me is.

  1. Clone MRTK, or add MRTK to a new project before opening it for the first time.
  2. Open the project with MRTK.
  3. Let MRTK configure your project for you.
  4. Try and make a build.

Expected behavior

Letting MRTK configure your project should not introduce errors.

Screenshots

image

Your setup (please complete the following information)

  • Unity Version [2018.4.12f1 and 2018.4.14f1]
  • MRTK Version [v2.2.0 and latest dev branch]

Target platform (please complete the following information)

  • HoloLens
  • HoloLens 2
  • WMR immersive
  • OpenVR

Additional Context

The exception in question is this

DirectoryNotFoundException: Could not find a part of the path "C:\Users\[username]\Documents\Github\MRTK\MixedRealityToolkit-Unity\Assets\MixedRealityToolkit.Providers\WindowsMixedReality\DotNetAdapter\Plugins\net46\Microsoft.Windows.MixedReality.DotNetWinRT\Editor\Microsoft.Windows.MixedReality.DotNetWinRT.Editor.asmdef"
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
System.IO.StreamReader..ctor (System.String path) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
(wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
System.IO.File.ReadAllText (System.String path) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.LoadCustomScriptAssemblyFromJson (System.String path) (at C:/buildslave/unity/build/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs:469)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.SetAllCustomScriptAssemblyJsons (System.String[] paths) (at C:/buildslave/unity/build/Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs:698)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
Microsoft.MixedReality.Toolkit.Build.Editor.UnityPlayerBuildTools:BuildUnityPlayer(IBuildInfo) (at Assets/MixedRealityToolkit/Utilities/BuildAndDeploy/UnityPlayerBuildTools.cs:114)
Microsoft.MixedReality.Toolkit.Build.Editor.<BuildPlayer>d__2:MoveNext() (at Assets/MixedRealityToolkit/Utilities/BuildAndDeploy/UwpPlayerBuildTools.cs:118)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<BuildPlayer>d__2&)
Microsoft.MixedReality.Toolkit.Build.Editor.UwpPlayerBuildTools:BuildPlayer(UwpBuildInfo, CancellationToken)
Microsoft.MixedReality.Toolkit.Build.Editor.<BuildPlayer>d__1:MoveNext() (at Assets/MixedRealityToolkit/Utilities/BuildAndDeploy/UwpPlayerBuildTools.cs:101)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<BuildPlayer>d__1&)
Microsoft.MixedReality.Toolkit.Build.Editor.UwpPlayerBuildTools:BuildPlayer(String, Boolean, CancellationToken)
Microsoft.MixedReality.Toolkit.Build.Editor.<BuildAll>d__105:MoveNext() (at Assets/MixedRealityToolkit.Tools/BuildWindow/BuildDeployWindow.cs:1134)
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(<BuildAll>d__105&)
Microsoft.MixedReality.Toolkit.Build.Editor.BuildDeployWindow:BuildAll(Boolean)
Microsoft.MixedReality.Toolkit.Build.Editor.<>c:<RenderWSABuildView>b__85_0() (at Assets/MixedRealityToolkit.Tools/BuildWindow/BuildDeployWindow.cs:316)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()```


About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 23 (18 by maintainers)

Most upvoted comments

The full path to the Microsoft.Windows.MixedReality.DotNetWinRT.Editor.asmdef file (that file name alone is 56 characters), is 184 characters, about 71% of the character limit for “regular paths” (vs “long paths”).

That full path is \MixedRealityToolkit.Providers\WindowsMixedReality\DotNetAdapter\Plugins\net46\Microsoft.Windows.MixedReality.DotNetWinRT\Editor\Microsoft.Windows.MixedReality.DotNetWinRT.Editor.asmdef

We also started running into a lot of long file path issues. With our build machines the first to have issues, because their automation pulls down the project a bit deeper than the root. And it was git complaining about not being able to pull down those files.

Also note that Windows Home also has a 256 character limit.

I’m not sure the fix is going to be in Unity, it’ll be best to just shorten the paths. I’d suggest not taking up more than 50-60% of the available limit, or 128 to 153 characters max.

We can do some work on our side to resolve that package to a shorter path (maybe a new MixedRealityToolkit.Plugins folder instead of nested several levels inside the .Providers folder).

As far as working around it, I’m not sure. There could be a change internal to Unity that could be made to support longer paths, but I think it’s a limit to the Windows APIs being used.

@jwlondon98 The paths are all much shorter in 2.4.

Good hunch @keveleigh!

I moved my folder to the root of my C drive, and then all the errors went away. Wonder if there’s some way to work around the path limit.