Jump to content
  • Advertisement
  • 09/22/17 03:19 AM

    Resolving build issues for UWP packages with Unity

    Engines and Middleware

    SimonDarksideJ

    Image result for visual studio tools for unity

    If you are building games and projects in Unity and targeting the Universal Windows Platform (UWP), you may have noticed than in the recent Unity releases this was actually broken. What you end up seeing in your build UWP project in visual studio is the following error:

    The command “”C:\ <Project>\Export\UWP\Unity\Tools\SerializationWeaver\SerializationWeaver.exe” “C:\ <Project>\Export\UWP\GeneratedProjects\UWP\Assembly-CSharp-firstpass\bin\x64\Debug\Unprocessed\Assembly-CSharp-firstpass.dll” “-pdb” “-verbose” “-unity-engine=C:\ <Project>\Export\UWP\Lonely Shadows\Unprocessed\UnityEngine.dll” “C:\ <Project>\Export\UWP\GeneratedProjects\UWP\Assembly-CSharp-firstpass\obj\x64\Debug\x64\Debug” “-lock=C:\ <Project>\Export\UWP\GeneratedProjects\UWP\Assembly-CSharp-firstpass\project.lock.json” “@C:\ <Project>\Export\UWP\GeneratedProjects\UWP\Assembly-CSharp-firstpass\SerializationWeaverArgs.txt” “-additionalAssemblyPath=C:\ <Project>\Export\UWP\Lonely Shadows\Unprocessed” “-unity-networking=C:\ <Project>\Export\UWP\Lonely Shadows\Unprocessed\UnityEngine.Networking.dll”” exited with code 1.
    Assembly-CSharp-firstpass          C:\ <Project>\Export\UWP\GeneratedProjects\UWP\Assembly-CSharp-firstpass\Assembly-CSharp-firstpass.csproj   

    If you dig further, you may also expose the underlying error code here:

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.ThrowHelper.ThrowKeyNotFoundException()
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at UnityEditor.Scripting.Compilers.NuGetPackageResolver.Resolve()
       at Unity.NuGetAssemblyResolver..ctor(String projectLockFile)
       at usw.Weaver.ReaderParameters(String assemblyPath, ConversionOptions options)
       at usw.Weaver.Weave()
       at usw.Program.RunProgram(ConversionOptions options)
       at usw.Program.Main(String[] args)

    This prevents you building / updating projects from Unity to the UWP Platform.

    Once discovered, both Unity and Microsoft worked closely together to resolve the issues and updated their respective parts as quickly as possible.


    Fixing the problem

    The fix for this problem is fairly easy. However, it is a little time consuming (unless you have a mega fast download connection) as mostly it requires updating to the latest Unity and Visual Studio patch releases.

    1: Install Unity 2017.1p5 or 2017.2.0f3

    Image result for unity logo

    The first step, is to simply update your installation of Unity:

    • If you are on Unity 2017, then this is 2017.1p5 (or newer)
    • If you are on Unity 2017.2, then this is 2017.2.0f3 (or newer)
    • For the 5.x cycle, just update to the latest patch (although I haven’t tested this)

    This will update both Unity and your install of the Visual Studio Tools for Unity

    2: Update VS 2017 to 15.3.3

    Once Unity is up to date, you will need to update your installation of Visual Studio.  If you are still on VS 2015, then there is no action but you won’t be able to build UWP packages targeting the newer Creators update and won’t be able to build Mixed Reality platform.

    I highly recommend updating to 2017, even the free Community edition of 2017 (which is free) if you are doing UWP development.  It’s just better.

    To update Visual Studio 2017, simple close all open instances of Visual Studio and launch the Visual Studio Installer

    image

    Once it’s running (the first step may be to update the installer first), simply hit “Update” on your specific instance of Visual Studio (the installer will happily update ALL installed instances if you wish) and once it’s complete you will be on the latest version.

    Open Visual Studio to verify, click “Help –> About Visual Studio” in the menu and you should be running 15.3.3 (or newer). If not, check your internet connection and try running the installer again.

    image

    3: (Optional) Set player settings for project to .NET & .NET4.6 
    (NOT IL2CPP, XBL project does not have support for IL2CPP, yet)

    Not strictly required but highly recommended for UWP projects, is to update the .NET Api Compatibility Level that is used in your built project.  This allows you to use more modern C# 6 functionality if you wish without causing errors when you build it in Unity.

    To update this, open the Player Settings window in the editor using either “Edit –> Project Settings –> Player” in the editor menu, or using the “Player Settings” button on the “Build Settings” build window.  In the Other section on this configuration page you will find the following settings.

    image

    Not to be confused with the “Scripting Runtime Version”, which I’m told breaks UWP project builds using Xbox Live (although I haven’t personally tested yet)

    Quote

    *Note, I'm not saying don't use IL2CPP (which is required for some Unity features, such as the new Post Processing stack) as it is a cleaner build.  It's just NOT compatible with the Xbox-Live-Unity plugin at present.

    4: Build project targeting UWP SDK 14393 or higher

    To build for Modern UWP, you need to be targeting a minimum API level of 14393 (Anniversary Edition), For Mixed Reality builds you will need a minimum API level of 15063 (Creators Update).  Either will work but you need to ensure you select the version that is right for your target.  The current advice with new builds is to always target the latest but that is completely up to you.

    You will find the SDK selection on the “Build Settings” screen when you have the “Universal Windows Platform” target selected:

    image

    5: Open project in VS

    Once you have built your project, open it in Visual Studio to continue.

    6: UPDATE NETCore NuGet package to 5.4+ <- without this, it still doesn’t work

    In testing I have found this is critical still for existing projects or when you build your first (ever) UWP project, you need to have the latest NETCore NuGet package downloaded and available else it will fail.  you don’t have to update the other NuGet packages if you don’t want to (UWP Packages come bundled with the Application Insights NuGets for Windows Store integration for example), just the NETCore package.

    When writing this article, I tried to replicate the error (after fixing it) and couldn’t generate the error even with new projects.  This step may not actually be needed but I still Highly Recommend updating any and all NuGet packages in your built project.

     

    If you are unsure as to what NuGet is, you can read all about it here. Basically, NuGet is a dependency manager for .NET solutions, allowing you to disconnect your project from the source of a dependency.  It can then be updated independently without affecting your project (unless the API changes).  You will find most modern .NET packages from Microsoft (like the .NET Framework) are now NuGet packages so they can more rapidly update the framework without having to build and distribute new MSI packages.

    To check and update the versions of the NuGet packages, right-click on the “Solution” in the “Solution Explorer” within Visual Studio and select “Manage NuGet Packages for Solution…

    image

    Alternatively, you can also simply right-Click the “References” branch in your projects structure, also in the “Solution Explorer” in VS, this however will only show/update the NuGet’s installed in that single project and not the entire solution:

    image

    Once the NuGet manager is open you will see the installed NuGet packages, with a notification if any updates are available (provided you have an internet connection).

    image

    Simply select the NuGet package to update, NETCore in this case, select the version to update to on the right and click “Install”.   You will then be walked through a set of screens to accept the license for that package (if one exists) and then a final “get out of jail free” accept or reject screen.   Once complete, all the required references included in that package will be updated.

    7: Build and Run for x64 only (x86 or Arm is a no go still)

    With everything in place, all that is left is to build your project. By default, Unity still insists on selecting the ARM platform as the default (don’t know why but I guess it’s too small a thing to want to change), so you will need to update this to the x64 platform (don’t use x86 unless you really need it, most UWP systems all target x64 now).  After that, you can build.

    If you are unsure about which Solution Configuration to select (read, Build Type), remember what they are there for:

    • Debug

      Used obviously for debugging, enables extra debugging information to be sent to an attached instance of Visual Studio (whether you run it from Visual Studio or just “attach” to it later).  Will cause a performance hit when running but this is needed so you can walk through the code if there are any issues.  It will also enable the debug window inside Unity to report errors to the screen should they occur.

    • Release

      Builds the project but without all the debugging stuff. just runs your project.  With Unity however, it’s keen to note you are still running your entire project with all the superfluous code that Unity has in a project.  DO NOT SHIP THIS!!!

    • Master

      This is a special Solution Configuration (just for Unity) that also runs code in Unity to strip mine unnecessary code / services and packages everything together neatly.  This makes your Unity project run as fast as it can.  <- SHIP/PUBLISH THIS!!!


    All well and good

    With everything in this article, you should have no further issues building your UWP projects and once you have gone through it at least once (I’ve found) you need not do it again (apart from updating NuGets, you should always do that)

    Any issues, let me know or comment on this post. 

     

    datesgrey-pdn

     


      Report Article


    User Feedback


    In response to Tautvydas Zilys comments (who is an awesome member of the Unity team!)

    1. I wouldn't recommend saying "no to IL2CPP" right away, especially if you haven't tried it. It is the future of scripting on UWP in Unity, and it is the default scripting backend for UWP in Unity 2017.2. We have no known issues with Xbox Live on IL2CPP, and there have been multiple games that shipped with IL2CPP and Xbox Live functionality. It also enables you to port your game to UWP much quicker compared to using .NET scripting backend, since you have exact same C# API surface on IL2CPP as other Unity platforms. On .NET, you only get a small "Microsoft blessed" subset of APIs.

    (SJ) Updated article to highlight this only relates to IL2CPP use with the Xbox Live Unity plugin.  There are many great features with IL2CPP that are worth exploring.

    2. 2017.2p9 doesn't exist. I assume you meant 2017.2.0b9?

    (SJ) I stand corrected.  Also updated since 2017.2 is now released

    3. "Not to be confused with the “Scripting Runtime Version”, which I’m told breaks UWP project builds" - that sounds like something that should be reported to us and addressed. I haven't heard anyone complain about this.

    (SJ) Tested myself with the Xbox Live Unity plugin and it doesn't work.  In fact any build attempting to use the Unity.Tasks DLL breaks using that build and makes Async inaccessible

    4. There is only one reason to target Windows SDK 14393 or newer: if you want to use APIs added to that SDK. Using any SDK is perfectly valid for shipping a UWP game.

    (SJ) Incorrect. Xbox LIVE is only supported from 14393 onwards.  This article was solely about Xbox Live UWP support, not general UPWP support (which yes, you can use any build that meets your criteria)

    5. The Unity logo is bastardized. I'm not sure where you took it from. You can find the proper one here: https://unity3d.com/public-relations/brand

    (SJ) The original logo did come from the Unity site, but I will use the updated branding in articles going forward. Thanks for the link

    As a side note.  There is now a way to use Xbox Live and IL2CPP but it is not for the feint hearted. You can't use the handy Xbox Live Unity asset (that won't work atm), so you have to build it yourself from scratch.
    See this article for more details:
    https://docs.microsoft.com/en-us/windows/uwp/xbox-live/get-started-with-partner/partner-unity-uwp-il2cpp

    Share this comment


    Link to comment
    Share on other sites


    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Advertisement
  • Game Developer Survey

    completed-task.png

    We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a $15 incentive for your time and insights. Click here to start!

    Take me to the survey!

  • Advertisement
  • Latest Featured Articles

  • Featured Blogs

  • Advertisement
  • Popular Now

  • Similar Content

    • By Burgos Games
      Official Website: https://nekoghostjump.com/
      Twitter: https://twitter.com/NekoGhostJump
      Developed By: Burgos Games https://burgosgames.com
      IndieDB: https://indiedb.com/games/neko-ghost-jump
      Neko Ghost Jump! is a Puzzle-Platforming Time Attack game where the player's objective is rather easy, they just need to make it to the end of the level as fast as possible. The puzzle part comes from the level design and the player's ability to shift between 2D and 3D perspectives (and as such, the need to know when/where to switch)
      It started out as a gamejam submission for Epic Games' 2019 Spring #ue4jam and we decided to continue working on it ever since then. We are currently in our 17th week of production and there have been many changes and additions and most definitely polish added.
      You can see some of the changes made in this comparison video: https://youtu.be/gthftG8rcFw
       

       
        We still have a ways to go, but progress is steady and each week brings us closer to release.  
    • By Gorillafruit studio CEO
      Hi there I'm looking at putting together a team to make a game in their free time, but here's the thing once the game is at a good alpha point I want to get it published as an early access game to help create a name for the studio we have started. 
      So if anyone one is interested in this opportunity please dont hesitate to reply.

      The game I have in mind is a open world survival game where you have make sure you can survive the night before all the creatures wake and hunt you down, I want it to be a 1st person shooter with block building and terrain manipulation, so you can dig and build how ever freely the players want. I want it to be multi player so people can team up. Also would like it to have a story mode, single or co-op. If you are interested please message or reply, we need people from all fields of game development. That's from story righter, artist, programmer, 3d artist and terrain/world creator to audio artist/producer. Once we have a team and have had a couple of meetings through Skype or what ever is easier for everyone and we have brain stormed ideas we will get on with making a game 
    • By Gorillafruit studio CEO
      Hi there I'm looking at putting together a team to make a game, I've been waiting for funds so me and my business partner can create a little game to get us started but unfortunately we just haven't been able to get the funds to make it. So I'm try a different Approach to it all. I'm looking at putting a group of people together to make a game in their free time for free, but here's the thing once the game is at a good alpha point I want to get it published as an early access game to help create the necessary funds to pay the team that we put together and eventually make enough money to fully employ the team.
      So if anyone one is interested in this opportunity please dont hesitate to reply.

      The game I have in mind is a open world survival game where you have make sure you can survive the night before all the creatures wake and hunt you down, I want it to be a 1st person shooter with block building and terrain manipulation, so you can dig and build how ever freely the players want. I want it to be multi player so people can team up. Also would like it to have a story mode, single or co-op. If you are interested please message or reply, we people from all fields of game development. That's from story righter, artist, programmer 3d artist and terrain/world creator to audio artist/producer. Once we have a team and have had a couple of meetings through Skype or what ever is easier for everyone and we have brain stormed ideas we will get on with making a game 
    • By DVeNom
      Hello, my name is Sean, and I and my friends are putting together a team to create an Open-World RPG. 
       
       
      As of right, it's all volunteer work. As we are wanting in the future that it will turn into something that people will want and love. If so all the people who volunteered will see their fair share. Even if this volunteer work it's also a great chance to show your skills and learn from other volunteers who joined the project. It's a chance to increase your resume on what you learned and what you have improved.
       
      Concept:
      The concept of the game is an MMORPG. I'm taking inspiration from games like Warcraft, Elder Scrolls, and Destiny and creating something new and refreshing. First, the game was going to be about Ancient Greece Mythology and having players meet the Gods, Mythical Creatures, and mythical locations throughout the map. But I decided to go a different route to rewrite the whole story and make something original, something where the rules don't matter as the story unfolds. There will be objectives to do every week to keep you coming back. I'm going for a rich narrative to have the players really get into the world that we are creating. There will be Dungeons, Raids, PvP, World Events, and Seasonal Events to have players always wanting more. 
       
      What I have
      I have two concept artist and 1 3D environmental artist. I have a website designer to show our work progress once the site is up. I have two coders. I also have me as story and lore.
       
       
      Volunteering Needs
       
      - Lead Sound Producer
      Will need original medieval-themed music, sound effect, etc. 
       
      - Lead Programmer
      What I am looking for in a Programmer is someone who has the ability to program graphics, gameplay, audio, and everything else.
       
      2-4  3D Environmental and Character Artists.
      Needing extra hands for 3D artists to make things go smoother and faster. I'm going for a more pitcher style graphics where the world would look amazing and beautiful.
       
      1 Lead Writer (Lore/Character)
      Need someone to help me with the story. I love being detailed oriented and love creating ideas. I need someone who can improve on what I have done.
       
       
      If you are interested you can send me an email with your application including a sample of work at ssingl2583@my.sullivan.edu with ”RPG” as the Subject. Or you can message me on discord and my GT is D4ddy VeNom#3970. If anyone has any questions you can just message me below or the given email/discord.
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!