8.2 compiler doesn't "see" System.Net.Sockets in UWP library project

Trying to compile a UWP library which uses System.Net.Sockets from the command line. The compiler complains about System.Net namespace. I’ve created a UWP library project in C# on the same system, and it can reference System.Net and System.Net.Sockets just fine (compiles the declarations and uses of the Socket class).

I have compared the project files (not just *.*proj, but also json files) and they almost identical. Looks like I am missing something very non-trivial (or it’s the compiler that is missing it). Do you have any idea of what could be wrong?

The strangest thing is that the test UWP library project created in the IDE is compiled just fine in the IDE, but fails to build in command-line with Elements.exe (the above error about no System.Net.Sockets) and with MSBuild.exe (can’t find Windows.Foundation.FoundationContract assembly, which is present). And MSBuild works fine in the IDE.

What am I missing?

Try using the Elements.exe from 8.3, or msbuild instead of Elements.exe.

It’s most likely a reference issue. you can see what it ends up passing to the compiler by setting msbuild output logging to detailed in Tools/Envinoment Options/Build.

I tried MSBuild.exe, it couldn’t resolve two references (FoundationContract and UniversalApiContract). When I added the references to those winmd files explicitly, FoundationContract is loaded fine, but UniversalApiContract can’t be loaded due to version 255.255.255.255 . The strange thing is that this happens only in my project, but not in the test project (the configuration of both is identical, mine just contains more files).

I am not sure that I want to try 8.3 at the moment, as it’s still in beta and we need to release the new version soon.

Turned out, that the problem with UniversalApiContract was caused by missing project.lock.json. BTW it seems that the name is hard-coded somewhere in Elements’ files, because if I include “SecureBlackbox.json” and create “SecureBlackbox.lock.json”, this doesn’t work, but project.lock.json solves the problem.