Skip to content

Commit e6da13c

Browse files
committed
[ECO-5624] Updated unity project with FAT Ably DLL
- Added cake script to build IO.Ably.Dll with all dependencies merged - Removed old dependencies from Ably/Plugins - Updated README and CONTRIBUTING guide
1 parent 86d5060 commit e6da13c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+98
-22785
lines changed

cake-build/tasks/build.cake

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,55 @@ Task("_Xamarin_Build")
104104
MSBuild(paths.XamarinSolution, settings);
105105
});
106106

107+
Task("_Build_Ably_Unity_Dll")
108+
.Description("Create merged Unity DLL with all dependencies")
109+
.Does(() =>
110+
{
111+
Information("Merging Unity dependencies into IO.Ably.dll...");
112+
113+
var netStandard20BinPath = paths.Src
114+
.Combine("IO.Ably.NETStandard20")
115+
.Combine("bin/Release/netstandard2.0");
116+
117+
if (!DirectoryExists(netStandard20BinPath))
118+
{
119+
throw new Exception($"NETStandard2.0 bin directory not found: {netStandard20BinPath}. Please build the project first.");
120+
}
121+
122+
var primaryDll = netStandard20BinPath.CombineWithFilePath("IO.Ably.dll");
123+
124+
if (!FileExists(primaryDll))
125+
{
126+
throw new Exception($"Primary DLL not found: {primaryDll}. Please build the IO.Ably.NETStandard20 project first.");
127+
}
128+
129+
var newtonsoftDll = paths.Root
130+
.Combine("lib/unity/AOT")
131+
.CombineWithFilePath("Newtonsoft.Json.dll");
132+
133+
if (!FileExists(newtonsoftDll))
134+
{
135+
throw new Exception($"Newtonsoft.Json.dll not found at: {newtonsoftDll}");
136+
}
137+
138+
var dllsToMerge = new[]
139+
{
140+
netStandard20BinPath.CombineWithFilePath("IO.Ably.DeltaCodec.dll"),
141+
netStandard20BinPath.CombineWithFilePath("System.Runtime.CompilerServices.Unsafe.dll"),
142+
netStandard20BinPath.CombineWithFilePath("System.Threading.Channels.dll"),
143+
netStandard20BinPath.CombineWithFilePath("System.Threading.Tasks.Extensions.dll"),
144+
newtonsoftDll
145+
};
146+
147+
var unityOutputPath = paths.Root.Combine("unity/Assets/Ably/Plugins");
148+
var outputDll = unityOutputPath.CombineWithFilePath("IO.Ably.dll");
149+
150+
// Merge all dependencies into primary DLL in one go
151+
ilRepackHelper.MergeDLLs(primaryDll, dllsToMerge, outputDll);
152+
153+
Information($"✓ Unity DLL created at: {outputDll}");
154+
});
155+
107156
///////////////////////////////////////////////////////////////////////////////
108157
// PUBLIC TARGETS
109158
///////////////////////////////////////////////////////////////////////////////
@@ -129,3 +178,8 @@ Task("Build.Xamarin")
129178
.IsDependentOn("_Clean")
130179
.IsDependentOn("_Restore_Xamarin")
131180
.IsDependentOn("_Xamarin_Build");
181+
182+
// Public task: Update Ably DLLs inside unity project
183+
Task("Update.AblyUnity")
184+
.Description("Update Ably DLLs inside unity project")
185+
.IsDependentOn("_Build_Ably_Unity_Dll");

lib/unity/AOT/Newtonsoft.Json.dll

670 KB
Binary file not shown.

unity/Assets/Ably/Plugins/NewtonsoftJsonAOT/Newtonsoft.Json.dll.meta renamed to lib/unity/AOT/Newtonsoft.Json.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@
6161

6262
<ItemGroup>
6363
<Reference Include="UnityEngine">
64-
<HintPath>..\..\lib\UnityEngine.dll</HintPath>
64+
<HintPath>..\..\lib\unity\UnityEngine.dll</HintPath>
6565
</Reference>
6666
</ItemGroup>
6767

68+
<!-- Copy all NuGet dependencies to output directory when building for unity package -->
69+
<!-- This ensures ILRepack can find all referenced assemblies via the /lib argument -->
70+
<PropertyGroup Condition=" $(DefineConstants.Contains('UNITY_PACKAGE')) ">
71+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
72+
</PropertyGroup>
73+
6874
</Project>

unity-plugins-updater.cmd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
if "%~1"=="" (echo "Provide latest version number like unity-plugins-updater.cmd 1.2.8") else (
33
dotnet tool restore
44
dotnet cake cake-build/build.cake -- --target=Build.NetStandard --define=UNITY_PACKAGE
5-
copy src\IO.Ably.NETStandard20\bin\Release\netstandard2.0\IO.Ably.dll unity\Assets\Ably\Plugins
6-
copy src\IO.Ably.NETStandard20\bin\Release\netstandard2.0\IO.Ably.pdb unity\Assets\Ably\Plugins
7-
copy src\IO.Ably.NETStandard20\bin\Release\netstandard2.0\IO.Ably.DeltaCodec.dll unity\Assets\Ably\Plugins
8-
copy src\IO.Ably.NETStandard20\bin\Release\netstandard2.0\IO.Ably.DeltaCodec.pdb unity\Assets\Ably\Plugins
5+
dotnet cake cake-build/build.cake -- --target=Update.AblyUnity
96
echo %~1 > unity\Assets\Ably\version.txt
107
)

unity-plugins-updater.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ then
44
else
55
dotnet tool restore
66
dotnet cake cake-build/build.cake -- --target=Build.NetStandard --define=UNITY_PACKAGE
7-
cp src/IO.Ably.NETStandard20/bin/Release/netstandard2.0/IO.Ably.dll unity/Assets/Ably/Plugins
8-
cp src/IO.Ably.NETStandard20/bin/Release/netstandard2.0/IO.Ably.pdb unity/Assets/Ably/Plugins
9-
cp src/IO.Ably.NETStandard20/bin/Release/netstandard2.0/IO.Ably.DeltaCodec.dll unity/Assets/Ably/Plugins
10-
cp src/IO.Ably.NETStandard20/bin/Release/netstandard2.0/IO.Ably.DeltaCodec.pdb unity/Assets/Ably/Plugins
7+
dotnet cake cake-build/build.cake -- --target=Update.AblyUnity
118
echo $1 > unity/Assets/Ably/version.txt
129
fi

unity/Assets/Ably/Examples/Chat/AblyChannelUiConsole.cs renamed to unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Assets.Ably.Examples.Chat
77
{
8-
internal class AblyChannelUiConsole
8+
internal class AblyChannel
99
{
1010
private readonly AblyRealtime _ably;
1111
private readonly IUiConsole _uiConsole;
@@ -19,15 +19,15 @@ internal class AblyChannelUiConsole
1919
private InputField _eventName;
2020
private InputField _payload;
2121

22-
private AblyChannelUiConsole(AblyRealtime ably, IUiConsole uiConsole)
22+
private AblyChannel(AblyRealtime ably, IUiConsole uiConsole)
2323
{
2424
_ably = ably;
2525
_uiConsole = uiConsole;
2626
}
2727

28-
internal static AblyChannelUiConsole CreateInstance(AblyRealtime ably, IUiConsole uiConsole)
28+
internal static AblyChannel CreateInstance(AblyRealtime ably, IUiConsole uiConsole)
2929
{
30-
return new AblyChannelUiConsole(ably, uiConsole);
30+
return new AblyChannel(ably, uiConsole);
3131
}
3232

3333
internal void RegisterUiComponents()

unity/Assets/Ably/Examples/Chat/AblyChannelUiConsole.cs.meta renamed to unity/Assets/Ably/Examples/Dashboard/AblyChannel.cs.meta

File renamed without changes.

0 commit comments

Comments
 (0)