Search Unity

Controlling il2cpp cl and link versions when VS2017 and VS2019 are both installed

Discussion in 'Windows' started by kaelswork, Aug 23, 2019.

  1. kaelswork

    kaelswork

    Joined:
    Apr 23, 2019
    Posts:
    2
    I'm running into some unexpected behavior when building my project on a computer with both VS2017 and VS2019. I want to build with VS2017 always (or at least have control over the choice) but the Il2Cpp build step is pointing to the VS2019 compiler and linker.

    Here's the steps my build goes though (this happens in Azure DevOps; we have a couple lab machines with Unity installed).

    1. Unity is invoked with -batchmode, calling into a custom build script with this content:

    Code (CSharp):
    1. EditorUserBuildSettings.wsaUWPVisualStudioVersion = string.Empty;
    2. EditorUserBuildSettings.wsaUWPSDK = "10.0.18362.0";
    3.  
    4. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
    5. EditorUserBuildSettings.SetPlatformSettings("WindowsStoreApps", "CopyReferences", "true");
    6.  
    7. BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    8. buildPlayerOptions.locationPathName = "UWP";
    9. buildPlayerOptions.targetGroup = BuildTargetGroup.WSA;
    10. buildPlayerOptions.target = BuildTarget.WSAPlayer;
    11. buildPlayerOptions.options = BuildOptions.None;
    12.  
    13. var enabledScenes = from scene in EditorBuildSettings.scenes
    14.                     where scene.enabled
    15.                     select scene.path;
    16. buildPlayerOptions.scenes = enabledScenes.ToArray();
    17.  
    18. BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
    2. The outputted folder is bundled up (that's why CopyReferences is set to true) and sent along to a build machine that likely doesn't have Unity installed since they're limited and we want to minimize the amount of time they're doing non-Unity things.

    3. On the Visual Studio build machine, VS2017 is specifically selected to build the sln. If VS2017 is the only version present, everything works fine. However, is VS2019 is also present, most things are build with 2017 but the Il2Cpp project gets a strange mix of settings:


    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe /fl /nologo /bl:F:\ACBUILD01C\_work\32\a\msbuild.binlog /dl:CentralLogger,F:\ACBUILD01C\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.151.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll;RootDetailId=5727cf14-3027-40b8-8183-10229d29a1eb|SolutionDir=F:\ACBUILD01C\_work\32\s\src\Tips\UWP*ForwardingLogger,F:\ACBUILD01C\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.151.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll /flp:logfile=F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips.sln.log;verbosity=diagnostic /m /nr:false /p:AppxBundle=Always /p:AppxPackageSigningEnabled=true /p:AppxBundlePlatforms=x86|arm /p:configuration=Master /p:VisualStudioVersion=15.0 /p:_MSDeployUserAgent=VSTS_cb55739e-4afe-46a3-970f-1b49d8ee7564_build_42943_0 F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips.sln
    Build started 8/13/2019 4:28:21 PM.
    1>Project "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips.sln" on node 1 (default targets).
    1>ValidateSolutionConfiguration:
    Building solution configuration "Master|ARM".
    1>Project "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips.sln" (1) is building "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\HoloLensTips.vcxproj.metaproj" (2) on node 1 (default targets).
    2>Project "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\HoloLensTips.vcxproj.metaproj" (2) is building "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\Il2CppOutputProject\Il2CppOutputProject.vcxproj" (3) on node 1 (default targets).
    3>Build:
    "F:\ACBUILD01C\_work\32\s\src\Tips\UWP\Il2CppOutputProject\\IL2CPP\build\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=ARMv7 -configuration=Release -platform=winrt -outputpath="F:\ACBUILD01C\_work\32\s\src\Tips\UWP\\build\bin\ARM\Master\GameAssembly.dll" --data-folder="F:\ACBUILD01C\_work\32\s\src\Tips\UWP\\build\bin\ARM\Master\\" -cachedirectory="F:\ACBUILD01C\_work\32\s\src\Tips\UWP\\build\obj\il2cppOutputProject\ARM\Master\\" -generatedcppdir="F:\ACBUILD01C\_work\32\s\src\Tips\UWP\Il2CppOutputProject\\Source" --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityaot -verbose --map-file-parser="F:\ACBUILD01C\_work\32\s\src\Tips\UWP\Il2CppOutputProject\\IL2CPP\MapFileParser\MapFileParser.exe"
    Building GameAssembly.dll with MsvcWinRtToolChain
    Msvc Install Version: 15.0
    Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
    Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.21.27702\bin\HostX64\ARM\link.exe
    Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.21.27702\bin\HostX64\ARM\cl.exe

    Output directory: F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\bin\ARM\Master
    Cache directory: F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\il2cppOutputProject\ARM\Master


    Later in the log, when building my native cpp files:


    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\arm\CL.exe /c /IF:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\ /I"Generated Files\\" /IF:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\ /IF:\ACBUILD01C\_work\32\s\src\Tips\UWP\Il2CppOutputProject\Source\CppPlugins /IF:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\ /I"Generated Files\\" /IF:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\ /Zi /ZW /ZW:nostdlib /nologo /W3 /WX- /diagnostics:classic /sdl /MP /O2 /Oi /Oy- /GL /D _UNICODE /D UNICODE /D UNITY_HOLOGRAPHIC=1 /D _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 /D _UNICODE /D UNICODE /D WINAPI_FAMILY=WINAPI_FAMILY_APP /D __WRL_NO_DEFAULT_LIB__ /Gm- /EHsc /MD /GS /guard:cf /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu"pch.h" /Fp"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\HoloLensTips.pch" /Fo"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\\" /Fd"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\vc141.pdb" /Gd /TP /wd4447 /wd4453 /wd4451 /wd4691 /wd28204 <kael: removed the huge list of /FU:*.winmd> /analyze- /FC /errorReport:queue /bigobj App.cpp Main.cpp F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\UnityGenerated.cpp
    App.cpp
    Main.cpp
    UnityGenerated.cpp
    Link:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\arm\link.exe /ERRORREPORT:QUEUE /OUT:"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\bin\ARM\Master\HoloLensTips.exe" /NOLOGO WindowsApp.lib F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\bin\ARM\Master\GameAssembly.lib WindowsApp.lib /MANIFEST:NO /DEBUG:FULL /PDB:"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\bin\ARM\Master\HoloLensTips.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /APPCONTAINER /WINMD /WINMDFILE:"F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\bin\ARM\Master\HoloLensTips.winmd" /DYNAMICBASE /NXCOMPAT /MACHINE:ARM /guard:cf F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\App.obj
    F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\Main.obj
    F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\pch.obj
    F:\ACBUILD01C\_work\32\s\src\Tips\UWP\build\obj\HoloLensTips\ARM\Master\UnityGenerated.obj
    F:\ACBUILD01C\_work\32\s\src\Tips\UWP\HoloLensTips\Resource.res


    Note the path for msbuild at the top is in 2017, and towards the bottom, when building GameAssembly.dll with il2cpp.exe, the paths to link.exe and cl.exe point to the 2019 install. Then in the step to build the other vcxproj with App.cpp and Main.cpp, the cl.exe and link.exe paths are in VS2017. The result of this build does work, but it requires updated vclibs to be installed with the package, the ones from VS2019. This is not something I want to do.

    I can't figure out how to be explicit about the paths that il2cpp.exe chooses. I see EditorUserBuildSettings.wsaUWPVisualStudioVersion can take some for of string, and empty implies "latest", but there isn't documentation about what should go into the string. Semver maybe? But that would be very hard to control if it had to be exact.

    How can I control which Visual Studio version my entire project builds with when both VS2017 and VS2019 are installed?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,436
    I believe right now there's no way to control this... IL2CPP always defaults to latest C++ compiler. Perhaps you could report a bug on this?

    By the way, what's the reason for not wanting updating vclibs? Aren't those automatically getting installed by the Windows Store?
     
  3. kaelswork

    kaelswork

    Joined:
    Apr 23, 2019
    Posts:
    2
    I'll file a bug. Having control over how the project is built is definitely something we want.

    The reasoning is a combination of factors. The main reason is really being able to have predictable and repeatable builds. With this il2cpp issue, the presence of VS2019 on the lab machine changes my build in a way I don't have control over. For vclibs in particular, the app I'm working on is pre-installed on HoloLens which means the vclibs packages are also preinstalled. With this issue, I'll need to pre-install the newer vclibs packages and ensure it doesn't break anyone else. I imagine just updating the app through the store after the fact will be fine. This is something the store handles.