Build Error (UWP)

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 :0
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in :0
at Mono.Cecil.TypeReference.Resolve () [0x00000] in :0
at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.GetConstantType (Mono.Cecil.TypeReference constant_type, System.Object constant) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddConstant (IConstantProvider owner, Mono.Cecil.TypeReference type) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddParameter (UInt16 sequence, Mono.Cecil.ParameterDefinition parameter, Mono.Cecil.ParamTable table) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddParameters (Mono.Cecil.MethodDefinition method) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddMethod (Mono.Cecil.MethodDefinition method) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddMethods (Mono.Cecil.TypeDefinition type) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) [0x00000] in :0
at Mono.Cecil.MetadataBuilder.AddTypeDefs () [0x00000] in :0
at Mono.Cecil.MetadataBuilder.BuildTypes () [0x00000] in :0
at Mono.Cecil.MetadataBuilder.BuildModule () [0x00000] in :0
at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00000] in :0
at Mono.Cecil.ModuleWriter+<>c.b__1_0 (Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _) [0x00000] in :0
at Mono.Cecil.ModuleDefinition.Read[MetadataBuilder,MetadataBuilder] (Mono.Cecil.MetadataBuilder item, System.Func3 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, IEnumerable1 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 (IEnumerable1 assemblies, IEnumerable1 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(IEnumerable1, IEnumerable1, 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, Action1, Action1) (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)

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?

Hi Tautvydas-Zilys,

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

Greetings.

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?

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.

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.

Yeah, this is unsupported. You’ll have to set that version to 5.0.0 in order for it to start working again.

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 :

#if WINDOWS_UWP && !UNITY_EDITOR
 using Windows.Networking.Connectivity;
 using Windows.Networking;
#endif

#if WINDOWS_UWP && !UNITY_EDITOR
 public static string GetLocalIp(HostNameType hostNameType = HostNameType.Ipv4)
        {
            var icp = NetworkInformation.GetInternetConnectionProfile();

            if (icp?.NetworkAdapter == null) return null;
            var hostname =
                NetworkInformation.GetHostNames()
                    .FirstOrDefault(
                        hn =>
                            hn.Type == hostNameType &&
                            hn.IPInformation?.NetworkAdapter != null &&
                            hn.IPInformation.NetworkAdapter.NetworkAdapterId == icp.NetworkAdapter.NetworkAdapterId);

            return hostname?.CanonicalName;
        }
#endif
//////////////////////////////////////////////////////////////////////
void AddHostToBDD(string data)
{
    string localAdress;

#if WINDOWS_UWP && !UNITY_EDITOR
            localAdress = GetLocalIp();
#else
            localAdress = Network.player.ipAddress;
#endif

...
}
////////////////////////////////////////////////////////////////////////////////////////

In any case I still do not know why.
Thanks for your help.

Greetings.

Can we get a bug report on this? I don’t think this is a known issue.

Tautvydas-Zilys,

Ok , i send you a report.

Greetings.

@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.

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?