I’ve been playing around with il2cpp for the Windows Store and wondering if doing a build on a beefier remote machine might speed things up.
I created a new Visual Studio Team Services account in Azure, committed everything in the C++ Visual Studio project generated by Unity into git, and pushed it up to the remote server. After configuring the build, when I try running it I get a failure at the first step, when it tries to run il2cpp.exe (which has been pushed up via git):
il2cpp.exe didn’t catch exception: System.InvalidOperationException: Builder is unable to build using selected toolchain (MsvcWinRtToolChain) or architecture (Unity.IL2CPP.Building.x86Architecture)!
at Unity.IL2CPP.Building.CppProgramBuilder.Build()
Any chance there’s a way around this, or is the whole thing an exercise in futility?
That error message means that either Visual Studio 2015/2017 or Windows 10 SDK is not installed on the machine. Probably the latter, since you were able to start the build. Are you able to install stuff into that VM? I’m not familiar with that azure service.
Somewhat related - did you try excluding your Unity project and generated VS project directories from Windows Defender on your local machine? It seems to slow down builds a lot with IL2CPP.
Thanks for the answer! I haven’t had time to return to this yet and see about getting the Windows 10 SDK up on Azure – since Visual Studio Team Services is for running builds in the cloud, I’m sure there’s some way to do it.
Thanks also for the advice about excluding the VS project directories for doing IL2CPP builds. I’m sure that’s going to help a lot.
According to Microsoft, both of the requirements are on the hosted agents that do their cloud builds (see here: https://www.visualstudio.com/en-us/docs/build/concepts/agents/hosted ). Looks like it has Visual Studio 2015 Update 3 as well as Windows 10 SDK 14393. Is there anything else that might be causing this? Is it possible the paths to the SDK are hard-coded in some build file such that it’s looking for the path on my local machine instead of the path where the build is installed on the cloud host?
Which exact Unity version are you on? There have been changes over time on how we detect those SDKs. On the latest Unity version, it’s detected as follows. First, we find Visual Studio 2015 install path:
Just upgraded from 5.5.0 to 5.5.1f1; still get the same error. Not sure how I’m going to get access to those registry keys, since the build hosts are shared and builds are just farmed out to them – there’s no way to log into them. I have a suspicion that the build doesn’t have access to those registry keys. I’ll see if I can get any advice on the forums for Visual Studio Team Services.
One more question: Is it necessary to run the C++ compilation step via il2cpp.exe? It would seem to me that once the C++ is generated, you should be able to compile the code into an executable using the Visual C++ compiler. What does il2cpp.exe add at this step? Might it be possible to circumvent it?
I have an idea, actually. Here’s a version of IL2CPP (just added some logging for you) which will print more information and hopefully allow us to troubleshoot your issue:
Just replace the il2cpp.exe in your VS solution with it, and when it runs, it will print more info. Paste its output here.
il2cpp.exe invokes the compiler is a special way. It knows exactly which flags to pass, which files to compile, which headers to include, etc. It also enables incremental building support - the piece which makes it possible to not recompile everything when you build on top of an existing project. Also, after building the binary, it parses the linker output in order to enable stack trace support.
Build:
“D:\a\1\s\Il2CppOutputProject\IL2CPP\build\il2cpp.exe” --libil2cpp-static --compile-cpp -architecture=x86 -configuration=Release -platform=winrt -outputpath=“D:\a\1\s\build\bin\Win32\Release\GameAssembly.dll” --data-folder=“D:\a\1\s\build\bin\Win32\Release\” -cachedirectory=“D:\a\1\s\build\obj\il2cppOutputProject\Win32\Release\” -generatedcppdir=“D:\a\1\s\Il2CppOutputProject\il2cppOutput” --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT -verbose
VS2015 installation folder was not found
Unhandled Exception: System.Exception: MSVC Installation version 14.0 or later is not installed on current machine!
at Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.GetLatestInstallationAtLeast(Version version)
at il2cpp.Program.Main(String[ ] args)
Very strange installation folder it’s looking for there.
Yeah, it looks like “SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir” registry key is not pointing anywhere… So we cannot find the VS installation folder.
Unfortunately, “We currently do not support building Unity projects on the hosted pool. Your best bet is to setup your own build agent on a VM with the necessary software and SDKs installed.”
Might be nice if you Unity folks could give Microsoft a nudge. Alternatively, maybe there’s a way for il2cpp.exe to have the install directories passed to it on the command line? Of course, this may not be the only issue. Still, it would be nice to have a cloud build for Windows Store apps, and this seems like it’s so close!
I’m trying out provisioning a build server in Azure, using the Visual Studio Community 2017 VM. It builds along fine with MSBuild until I get to this point:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1956,5): warning MSB3106: Assembly strong name “C:\Program Files\Unity 5.6.0b7\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\il2cpp\ARM\Debug\UnityPlayer.winmd” is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(). [C:\Users\psfblair\Documents\repositories\holobuild\Origami\Origami.vcxproj]
I had created the C++ project locally from Unity 5.6.0b7, which is not currently installed on the build server. Do I need to have Unity installed in order to run the C++ build?
@psfblair no, but you need to check “Copy References” checkbox in the build window before building your project, because otherwise Unity will not copy those files and instead reference them directly from Unity’s installation directory. It is made so by default it wouldn’t copy them saving build time.
In case you folks are interested in it, I’ve got a fully-functioning automated headless build for Windows Store up in the cloud. I blogged about it in the following three posts:
Is there a way to script setting “Copy References” ? I have found all the other settings available in the EditorUserBuildSettings class but can’t seem to find a way to set “Copy References.”
Thanks for your reply!
Unfortunately, the BuildPipeline.GetBuildTargetName method is inaccessible due to its protection level (using Unity 2017.1.0f3).
I naively tried to use “WSAPlayer” as the name but that didn’t work.
Could you please provide me the string literal value that corresponds to BuildTarget.WSAPlayer?