Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Build Error (UWP)

Discussion in 'Windows' started by gerardB_fr, Apr 1, 2018.

  1. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Hi,

    Since yesterday i can not compile anymore for uwp, here is the error displayed in the editor:

    UNetWeaver error: Exception :Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Windows.Foundation.UniversalApiContract, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null'
    at Unity.SearchPathAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x000e0] in C:\buildslave\unity\build\Tools\Unity.NuGetPackageResolver\SearchPathAssemblyResolver.cs:66
    at Unity.NuGetAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x0009c] in C:\buildslave\unity\build\Tools\Unity.NuGetPackageResolver\NuGetAssemblyResolver.cs:52
    at Unity.SearchPathAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00011] in C:\buildslave\unity\build\Tools\Unity.NuGetPackageResolver\SearchPathAssemblyResolver.cs:43
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.TypeReference.Resolve () [0x00000] in <filename unknown>:0
    at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.GetConstantType (Mono.Cecil.TypeReference constant_type, System.Object constant) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddConstant (IConstantProvider owner, Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddParameter (UInt16 sequence, Mono.Cecil.ParameterDefinition parameter, Mono.Cecil.ParamTable table) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddParameters (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddMethods (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.AddTypeDefs () [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.BuildTypes () [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.BuildModule () [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleWriter+<>c.<BuildMetadata>b__1_0 (Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Read[MetadataBuilder,MetadataBuilder] (Mono.Cecil.MetadataBuilder item, System.Func`3 read) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
    at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x00313] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1878
    at Unity.UNetWeaver.Weaver.WeaveAssemblies (IEnumerable`1 assemblies, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x0006e] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1904
    UnityEngine.Debug:LogError(Object)
    Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
    Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1912)
    Unity.UNetWeaver.Program:process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
    UnityEditor.HostView:OnGUI()

    Greetings.
    (Windows 10 Creators, Unity 2017.1.1f1, Scripting > .Net 3.5, Backend > .Net, API > .Net 2.0)
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Did you change anything with regards to your Windows SDK installation? Do you have "Windows.Foundation.UniversalApiContract.winmd" somewhere under C:\Program Files (x86)\Windows Kits\10\References?
     
  3. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Hi Tautvydas-Zilys,

    Yes, here :
    C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\3.0.0.0\

    Greetings.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Did you change anything with regards to your Windows SDK installation? You used to be able to build before, right? Are you able to create and build empty UWP apps from Visual Studio?
     
  5. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Hi Tautvydas-Zilys,

    Yes before yesterday i compiled perfectly.
    The only thing i updated in another uwp project (chessuccess) that's
    the Microsoft.NETCore.UniversalWindowsPlatform package> v6.08.

    Greetings.
     
  6. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Tautvydas-Zilys,

    Here too :
    C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.UniversalApiContract\5.0.0.0

    I tried to compile for all versions of sdk, modifying the target API (4.6) always the same error. If I try with a new project (uwp) the compilation is ok, but not with my current project.
    Compilation stops to restore nuget packages.

    Greetings.
     
    Last edited: Apr 3, 2018
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Yeah, this is unsupported. You'll have to set that version to 5.0.0 in order for it to start working again.
     
  8. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Tautvydas-Zilys,

    I also thought that was the problem but the error remained after downgrade the version (6.0.8 > 5.0.0) in the package manager.
    In fact the problem comes from a new scipt (i implement an online mode for the game), if i put it in comment before compilation it compiles, just have to uncomment before publishing on the store :
    Code (CSharp):
    1.  
    2.  
    3. #if WINDOWS_UWP && !UNITY_EDITOR
    4.  using Windows.Networking.Connectivity;
    5.  using Windows.Networking;
    6. #endif
    7.  
    8. #if WINDOWS_UWP && !UNITY_EDITOR
    9.  public static string GetLocalIp(HostNameType hostNameType = HostNameType.Ipv4)
    10.         {
    11.             var icp = NetworkInformation.GetInternetConnectionProfile();
    12.  
    13.             if (icp?.NetworkAdapter == null) return null;
    14.             var hostname =
    15.                 NetworkInformation.GetHostNames()
    16.                     .FirstOrDefault(
    17.                         hn =>
    18.                             hn.Type == hostNameType &&
    19.                             hn.IPInformation?.NetworkAdapter != null &&
    20.                             hn.IPInformation.NetworkAdapter.NetworkAdapterId == icp.NetworkAdapter.NetworkAdapterId);
    21.  
    22.             return hostname?.CanonicalName;
    23.         }
    24. #endif
    25. //////////////////////////////////////////////////////////////////////
    26. void AddHostToBDD(string data)
    27. {
    28.     string localAdress;
    29.  
    30. #if WINDOWS_UWP && !UNITY_EDITOR
    31.             localAdress = GetLocalIp();
    32. #else
    33.             localAdress = Network.player.ipAddress;
    34. #endif
    35.  
    36. ...
    37. }
    38. ////////////////////////////////////////////////////////////////////////////////////////
    39.  
    In any case I still do not know why.
    Thanks for your help.

    Greetings.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Can we get a bug report on this? I don't think this is a known issue.
     
  10. gerardB_fr

    gerardB_fr

    Joined:
    Jul 21, 2016
    Posts:
    28
    Tautvydas-Zilys,

    Ok , i send you a report.

    Greetings.
     
  11. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    @Tautvydas-Zilys we are getting the same error when trying to build for hololens and this is completely stopping our development. Tried multiple versions of unity but same issue about UNetWeaver across the board. It is very irritating that this error causes all our scripts not to compile because we have no way of fixing an error in unity itself.

    Can we please get a timescale on the fix for this, as we are using the latest officially supported version of unity and do not expect long standing issues such as this to still be making it into builds. Going through issuetracker shows this issue has existed for a long time and continues to be reported as fixed, which makes me think "whats the point of me supplying a bug report then?".

    I will hapily submit a bug report but it looks like it will be just set to "fixed" as according to issue tracker this issue is "fixed" despite many users reporting sporadic issues with it still for last 6 months.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Which specific error are you getting? The cases that say are fixed on the issue tracker are fixed, and covered by automated tests. Could you give a link to an issue that says fixed but actually isn't?