aws-samples / amazon-gamelift-unity

A multi-player game sample (server and client), developed with the Unity game engine, illustrating basic integration with Amazon GameLift. View the sample source code or build the project and experiment with game server deployment on the Amazon GameLift service.
Apache License 2.0
82 stars 22 forks source link

Failed to Build (System.Memory.dll not allowed to be included or could not be found) #16

Open EdevJogos opened 2 years ago

EdevJogos commented 2 years ago

Failed to Build it seems like (System.Memory.dll not allowed to be included or could not be found)

ArgumentException: The Assembly System.Runtime.CompilerServices.Unsafe is referenced by System.Memory ('Assets/Plugins/System.Memory.dll'). But the dll is not allowed to be included or could not be found. Extracting referenced dlls failed. Building Player failed Component GUI Layer in Main Camera for Scene Assets/Scene/scene.unity is no longer available. It will be removed after you edit this GameObject and save the Scene. Failed to build player. Exiting without the bug reporter. Application will terminate with return code 1

Full Editor.log: Editor.log

alanmur commented 2 years ago

Hello, I tried to reproduce your issue, but I did not encounter it when I tried. I did log my repro steps (shown at the end of this post). I don't know if you tried to build the project with the included build script. This automatically does some required steps, like downloading and building the GameLift SDK which is then put into the Assets\Plugins directory for use by Unity, and it also does a Unity build for both the game server and the game client. You are using a much newer version of Unity than the sample (or GameLift SDK) was created with, and Unity keeps making breaking changes, so keeping up with that can be a problem. I will list the steps you probably need to take, but include the steps I took for my own successful build as additional reference.

  1. Install Unity, and Visual Studio 2019 Community edition which the Unity installer includes as an option.
  2. Restart your computer to finish installation of Visual Studio 2019
  3. Run the Visual Studio 2019 installer, and make sure the .NET Desktop development workload is installed. Probably restart again.
  4. Clone the GitHub repository.
  5. Open the project in Unity using the Unity Hub to find it. (Ignore safe mode if it says anything about that, and do not try to build the player).
  6. Close Unity Editor.
  7. Run the Build\build.bat file.
  8. Everything should work. The result should look like this at the end.

BUILDING Server The system cannot find the path specified. USING "C:\Program Files\Unity\2021.1.26f1\Editor\Unity.exe" TO BUILD BUILD COMPLETED SUCCESSFULLY. SEE C:\Users\alanmur\AppData\Local\Unity\Editor\Editor.log

BUILDING Client The system cannot find the path specified. USING "C:\Program Files\Unity\2021.1.26f1\Editor\Unity.exe" TO BUILD BUILD COMPLETED SUCCESSFULLY. SEE C:\Users\alanmur\AppData\Local\Unity\Editor\Editor.log

IF you get the same error as I do in my STEP 11 below, then take the same steps (exactly) to remediate.

Then follow the rest of the instructions in the readme to deploy the server and connect using the client.

For additional reference, here are the steps that I took.

GOOD LUCK! Let me know if that helps, or if I can assist further.

  1. I downloaded the same version of Unity as you are using.

  2. I restarted the computer after Visual Studio 2019 Community had installed.

  3. I cloned the repository into a directory on my computer.

  4. I ran the Build\build.bat file in the terminal. This downloaded the GameLift Server SDK 4.0.0. This project targets .NET Framework 4.5, which is no longer supported with a Dev Pack.

  5. I opened the following file in the Visual Studio 2019 that was installed. aws-samples\amazon-gamelift-unity\SDK\GameLift_04_16_2020\GameLift-SDK-Release-4.0.0\GameLift-CSharp-ServerSDK-4.0.0\GameLiftServerSDKNet45.sln

  6. I chose to retarget the project to .NET 4.6.1. Visual Studio asked me to install the .NET for Desktop Visual Studio workload. (Weirdly enough this installed the .NET 4.5 targeting pack).

  7. I built the GameLift SDK in Visual Studio 2019 to validate that we are successful.

  8. I retargeted the GameLift SDK project BACK to 4.5, and it built now. You must already have got this far.

  9. I went back to the command line and ran the Build\build.bat file.

  10. buildconfig.bat couldn't find Unity. I manually set the file in buildconfig.bat by addiong this at line 86:

    IF EXIST "%ProgramFiles%\Unity\2021.1.26f1\Editor\Unity.exe" SET UNITYEXE="%ProgramFiles%\Unity\2021.1.26f1\Editor\Unity.exe"

  11. I went back to the command line and ran the Build\build.bat file. I got this error in the Editor.log.

    Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform. (C:/aws-samples/amazon-gamelift-unity/Library/PackageCache/com.unity.nuget.newtonsoft-json@2.0.0/Runtime/Newtonsoft.Json.dll) Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform. (Assets/Plugins/Newtonsoft.Json.dll) Scripts have compiler errors.

  12. To fix that, I went into aws-samples\amazon-gamelift-unity\Assets\Plugins and deleted the Newtonsoft.Json.dll.meta and Newtonsoft.Json.dll files.

  13. From the command line at aws-samples\amazon-gamelift-unity\Build I used buildconfig.bat Server to build the server (success). Capitalized S in Server is required!

  14. From the command line at aws-samples\amazon-gamelift-unity\Build I used buildconfig.bat Client to build the client (success). Capitalized C in Client is required.

The project build is complete now and you can deploy the server with the deploy.bat script according to the instructions in the readme.

EdevJogos commented 2 years ago

Hi, thanks for the detailed guide, i'll try it out.