googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.21k stars 336 forks source link

[Question] How to build from source #658

Open derwaldgeist opened 7 months ago

derwaldgeist commented 7 months ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

I am trying to build the project from source. I installed JDK 11 on my Mac, since I realized that the Gradle version required was not working with a newer JDK.

However, I am still running into an error:

> Configure project :
Mono 6.13.0 detected which will generate .pdb files that are not compatible with older versions of Unity. This can be fixed by compiling with Unity 5.6.

> Task :compileVersionHandler FAILED

>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<

XBuild Engine Version 4.0
Mono, Version 6.13.0.0
Copyright (C) 2005-2013 Various Mono authors
/Users/tom/dev/marble/libraries/unity-jar-resolver/source/ExternalDependencyManager.sln:  warning : Project file /Users/tom/dev/marble/libraries/unity-jar-resolver/source/JarResolverTests/JarResolverTests.csproj referenced in the solution file, not found. Ignoring.
/Users/tom/dev/marble/libraries/unity-jar-resolver/source/ExternalDependencyManager.sln:  warning : Project file /Users/tom/dev/marble/libraries/unity-jar-resolver/source/VersionHandlerImpl/unit_tests/VersionHandlerImplTests.csproj referenced in the solution file, not found. Ignoring.
/Users/tom/dev/marble/libraries/unity-jar-resolver/source/ExternalDependencyManager.sln:  warning : Project file /Users/tom/dev/marble/libraries/unity-jar-resolver/source/PackageManagerResolver/unit_tests/PackageManagerResolverTests.csproj referenced in the solution file, not found. Ignoring.
src/VersionHandler.cs(32,2): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/tom/dev/marble/libraries/unity-jar-resolver/build.gradle' line: 1030

* What went wrong:
Execution failed for task ':compileVersionHandler'.
> Process 'command '/Applications/Unity/Hub/Editor/2022.3.11f1/Unity.app/Contents/MonoBleedingEdge/bin/xbuild'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Note that this Unity Editor version is an Apple Silicon build. It seems as if the build script is using the first Editor it can find.

google-oss-bot commented 7 months ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

derwaldgeist commented 7 months ago

I tried to uninstall the 2023.3.11f1 Editor in favor of 2023.3.13f1, hoping it would pickup the Intel version, but then I got

Unity editor executable (UNITY_EXE) not found

derwaldgeist commented 7 months ago

Did some additional research. It did not find the Unity application since it stores its path in gradle.properties on first run. I don't think this is a good idea, since Unity installations tend to change often.

After I removed the content of this file, I am now getting this again:

Process 'command '/Applications/Unity/Hub/Editor/2022.3.13f1-x86_64/Unity.app/Contents/MonoBleedingEdge/bin/xbuild'' finished with non-zero exit value 1

I tried with both the Silicon and Intel versions of Unity. But both show the same problem, even if I run gradlew with Rosetta.

derwaldgeist commented 7 months ago

I ran gradlew again, but patched the verbosity level in line 1044 to "detailed".

This resulted in this log:

/Users/tom/dev/marble/libraries/unity-jar-resolver/source/ExternalDependencyManager.sln (VersionHandler) ->
(VersionHandler target) ->
/Users/tom/dev/marble/libraries/unity-jar-resolver/source/VersionHandler/VersionHandler.csproj (default targets) ->
/Applications/Unity/Hub/Editor/2022.3.13f1-x86_64/Unity.app/Contents/MonoBleedingEdge/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

    src/VersionHandler.cs(32,2): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

     3 Warning(s)
     1 Error(s)

for both the Silicon and the Intel versions of the Unity editor.

If I understand things correctly, this attribute is breaking things: https://github.com/googlesamples/unity-jar-resolver/blob/ae200afe800c179e7d24d8b5653cbe71bcd238b7/source/VersionHandler/src/VersionHandler.cs#L32