Search Unity

Problem Passing Windows App Certification Kit Tests When Referencing Runtime Component Library

Discussion in 'Windows' started by sidzanuff, Apr 10, 2019.

  1. sidzanuff

    sidzanuff

    Joined:
    Apr 10, 2019
    Posts:
    5
    I have a project in Unity 2018.14.f1. When I export the project as UWP application and build the store package all WACK tests pass fine, but as soon I add a reference to Windows Runtime Component library, I get the following errors:

    The binary analyzer test detected the following errors:
    - File C:\Program Files\windowsapps\26720randomsaladgamesllc.backgammondeluxe_3.4.11.0_x64__kx24dqmazqk8j\clrcompression.dll has failed the AppContainerCheck check.
    - File C:\Program Files\windowsapps\26720randomsaladgamesllc.backgammondeluxe_3.4.11.0_x64__kx24dqmazqk8j\clrjit.dll has failed the AppContainerCheck check.

    It happens even on plain empty Unity project referencing plain empty library. What can I do to fix this?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    In Visual Studio, you need to build the game in Master config.
     
  3. sidzanuff

    sidzanuff

    Joined:
    Apr 10, 2019
    Posts:
    5
    Yes, I know, and I do.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    This usually happens when .NET native isn't run.

    Are you running WACK locally or did you submit the app to Microsoft? If you're running locally, did you by any chance make a appx package that's "I'm going to upload this to the Windows Store"?
     
  5. sidzanuff

    sidzanuff

    Joined:
    Apr 10, 2019
    Posts:
    5
    Last edited: Apr 11, 2019
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    .NET native is a build option that is enabled by default in Master builds on .NET scripting backend. It is required to pass WACK. It could have been disabled on your project for some reason. You can check whether it's enabled in project properties in Visual Studio:

    upload_2019-4-11_15-3-1.png

    Generally, any .NET DLLs and WINMDs must be compiled to native code one way or another before they're uploaded to the store. .NET native is one way, and Unity uses that for .NET scripting backend. Another one is IL2CPP, which is actually the default scripting backend.

    EDIT: I just checked what you attached. What I wrote earlier doesn't apply - you're using IL2CPP scripting backend with a C++ project (I assumed you used .NET scripting backend - since that's where those errors usually appear). This happens because you include a managed project reference in the generated C++ project. Is there a reason you're doing that?
     
  7. sidzanuff

    sidzanuff

    Joined:
    Apr 10, 2019
    Posts:
    5
    Yes, that managed project reference is my library project written in C#.
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    To be honest, I don't know how to enable .NET native for a Windows Runtime component when the main app project is in C++ (this is a UWP problem, not Unity specific) problem.

    I know of two solutions that might work:

    1. Put the Windows Runtime component inside your Unity project, rather than the generated VS project. This way it will get converted with the rest of your scripts to C++ via IL2CPP.
    2. Convert the main generated project into C#, while maintaining the references to Unity components and files it needs.
     
  9. sidzanuff

    sidzanuff

    Joined:
    Apr 10, 2019
    Posts:
    5
    1. If I try moving the code from my Runtime Component into unity project it complains about some missing references (I'm using UWP specific code there). I tried building the component as winmd file and then putting it in Assets folder but it also didn't work (the classes contained in the component weren't visible in the generated project)
    2. I'm not sure how to do that, any hints?

    I tried making basic UWP C++ project and then referencing Runtime Component, and generated package passed all tests fine so it looks like somewhat Unity related issue.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I made an example project showcasing it here:

    https://github.com/TautvydasZilys/unity-uwp-il2cpp-with-csharp-project-example/tree/master/bin

    Did you try comparing the basic UWP C++ project file with the one Unity generates? We don't really do anything special with it.
     
  11. Monguskan

    Monguskan

    Joined:
    Jan 2, 2013
    Posts:
    4
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    1. Build from Unity;
    2. Create a C# project and add references to files Unity generated.

    That's pretty much it.
     
  13. livingtarget

    livingtarget

    Joined:
    Apr 21, 2015
    Posts:
    83
    I've figured out why Visual Studio and NuGet try to inject the framework. Not sure why it's not happening for everyone or what the conditions actually are, but most importantly here's the fix:
    Code (CSharp):
    1. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets
    Open this file where it says:
    <!--
    ============================================================
    Framework injection into mixed-target applications
    ============================================================
    -->

    Delete the XML that does the framework injection. For me that was up until:
    <Import Project="$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.targets" Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.targets') AND '$(IncludeNuGetImports)' != 'false'" />
    </Project>

    Now Visual Studio won't try to inject the framework randomly into your Unity project. No idea why the injection conditions don't catch it, but that's for Unity or Visual Studio/NuGet to figure out.

    This way it built fine and passed Wack testing.
     
    Hoofmaster likes this.