Skip to content

add UWP project to test .NETNative compilation - #638

Closed
bruzkovsky wants to merge 5 commits into
MessagePack-CSharp:masterfrom
gentledepp:add-uwp-project
Closed

bruzkovsky wants to merge 5 commits into
MessagePack-CSharp:masterfrom
gentledepp:add-uwp-project

Conversation

@bruzkovsky

@bruzkovsky bruzkovsky commented Nov 13, 2019 •

Copy link
Copy Markdown

This adds a UWP project to sandbox/ where the .NETNative compilation can be tested. It is enabled for Debug and Release configuration. Currently, the build fails with the message

error : ILT0005: '[...]nutc_driver.exe @"[...]\MessagePack-CSharp\obj\TestUAP_NETNative\x86\Release\ilc\intermediate\MDIL\TestUAP_NETNative.rsp"' returned exit code -2147483645

as discussed in #401

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

FWIW I've created a UWP test project in the solution of the master branch (on my local box only, so far) that compiles and has many of the unit tests loaded. When compiling with the .NET Native toolchain, it fails with this:

C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): error : MCG0037: MCG0037:InvalidCSharpIdentifierName Struct 'UnityEngine.Bounds' in assembly 'Assembly(Name=MessagePack.UnityShims, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b4a0369545f0a1be)' has a field with name '<center>k__BackingField' that is invalid. This could be because the name is obfuscated or the field is auto-implemented by the compiler. Please make sure the field name follows C# identifier conventions.

This may be simple to solve, I'm not sure. I'll look more into it later. Or you can if you get to it first. It's over at https://github.com/AArnott/MessagePack-CSharp/tree/uwptests

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

I'm seeing it locally too in the simplest UWP test project that references MessagePack. I've opened an issue with the .NET Native tool chain (see above) to ask for advice.

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

I was able to get a UWP test project working with a basic MessagePack test.
I also observed that a trivial UWP test project with no MessagePack related references worked until I added a PackageReference to Nerdbank.Streams at which point it failed with the exit code you mentioned above. I have no idea what Nerdbank.Streams is doing that might upset .NET Native, but that's where I should probably focus my investigation since messagepack depends on nerdbank.streams.

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

I found the root cause and updated my dotnet/corert issue linked above.

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

It's something I should be able to workaround.

@bruzkovsky

Copy link
Copy Markdown
Author

That sounds very promising. You are my hero! 💫
After more searching, I found a maybe related issue already on corert: dotnet/corert#7372

__makeref seems to be not supported ATM.

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

The unsupported code in question is in the vs-threading library. I'm preparing a change so that it builds a UAP-specific package that omits the unsupported code.

@AArnott

AArnott commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

Tracked by this issue: microsoft/vs-threading#557

@bruzkovsky

Copy link
Copy Markdown
Author

I changed to solution config so that the project builds with Release|AnyCpu. Does the CI get triggered by pushes or must something else be done?

@AArnott

AArnott commented Nov 15, 2019

Copy link
Copy Markdown
Collaborator

The PR build would be triggered by your push except for the merge conflicts.

@bruzkovsky

Copy link
Copy Markdown
Author

Ok, makes sense.

@AArnott

AArnott commented Nov 16, 2019

Copy link
Copy Markdown
Collaborator

#642 contains fixes that should allow your UWP project to compile properly.

@bruzkovsky

Copy link
Copy Markdown
Author

The build fails because the nuget packages are not restored for the UWP project, see this output for reference:
d:\a\1\s\sandbox\TestUAP_NETNative\TestUAP_NETNative.csproj : warning NU1503: Skipping restore for project 'd:\a\1\s\sandbox\TestUAP_NETNative\TestUAP_NETNative.csproj'. The project file may be invalid or missing targets required for restore. [d:\a\1\s\MessagePack.sln]

I did some digging and this is what I could find: NuGet/Home#6665

Is there any way that the CI could use msbuild -t:restore for windows? Or the other option seems to be modifying the UWP csproj to be SDK-style, but I have no idea how that should be done.

@AArnott

AArnott commented Nov 19, 2019

Copy link
Copy Markdown
Collaborator

@bruzkovsky I don't think that's the problem. At least when I tried this on my own UWP test project, I noticed restore didn't work unless I specified the platform of x86 or x64. Since AnyCPU is the default solution platform and the UWP project doesn't participate in that, the "build" skips it, and restore is based on msbuild so restore doesn't happen.

So ya, I suspect I know how to fix that.

I hope to take a look at this PR some more later this week. I might build on it or take my own attempt instead if I feel it will get us closer to actually running most of our tests within the UWP app as well.

@bruzkovsky

bruzkovsky commented Nov 19, 2019 via email •

Copy link
Copy Markdown
Author

@AArnott

AArnott commented Dec 4, 2019

Copy link
Copy Markdown
Collaborator

This PR only adds a UWP project with a project reference, which now works. I'm preparing a change that adds a UWP test project that will actually run our tests within the UWP app, which reveals it's totally broken (and tracked by #159).
I'm closing this PR since it will be obsolete with the work I'm doing. But thank you for raising the concern. It was the trigger for me to investigate this and fix the issues.

@AArnott AArnott closed this Dec 4, 2019
@AArnott AArnott mentioned this pull request May 4, 2020
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants