Combined Third-Party-Dll like in Unity's LocalizationPackage?

Hello,

I just stumbled uppon a combined third-party dll in the official Localization-UnityPackage.
(combined all the necessary google / csv-helper .dlls into one .dll referenced in the editor-assembly definition)
7993482--1027284--upload_2022-3-25_13-26-41.png
Does anyone know if that’s easy to do?

I tried creating a class-library with embedded resources, but the guide I followed came to the step of explicitly loading them via Application-Domain in the main-function of a script inside the new library and I wondered if that is even possible to use in unity that way, does unity call such a main-method and allows explicitly loading such an embedded dll?
I also read about using ILMerger to combine assemblies / dlls, but I’m not sure if that works with Unity either. Does anybody have an idea how Unity did it within the localization-package and is able nudge me in the right direction?
I’m trying to reduce the mess when working with a third party cloud-service (20+ editor - dll dependencies required)

This sub-forum and the devs there might be of better use to you: Localization Tools.

I can move your post there if you wish.

1 Like

Hello MelvMay,

That would be great thanks, I wasn’t sure whether to post here or over there, since it’s more of a meta-scripting question :slight_smile:

1 Like

I’ll leave a redirect link here for a week for you.

We do use ILMerge to combine our dependencies. We have a Visual Studio Project that pulls a bunch of nuget packages and then combines them.

This is the project

Unity.Localization.ThirdParty.Editor.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net4.5</TargetFramework>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference Include="ILMerge" Version="3.0.41" />
    <PackageReference Include="CsvHelper" Version="15.0.9" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  <PackageReference Include="Google.Apis.Sheets.v4" Version="1.49.0.2111" />
  </ItemGroup>

  <!--This only executes during a Release build /-->
  <Target Name="ILMerge" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
    <PropertyGroup>
      <WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework)</WorkingDirectory>
      <TargetDestination>$(MSBuildThisFileDirectory)../../Packages/com.unity.localization/Editor</TargetDestination>
    </PropertyGroup>
    <ItemGroup>
      <!--These are the depdendencies that will be merged /-->
 
      <!--Google Sheets /-->
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Newtonsoft.Json'" />
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Google.Apis.Core'" />
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Google.Apis.Sheets.v4'" />
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Google.Apis.Auth.PlatformServices'" />
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Google.Apis.Auth'" />
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Google.Apis'" />
 
      <!--CsvHelper /-->
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'CsvHelper'" />
 
    </ItemGroup>
 
  <!--This is where we execute ILMerge with the list of dll's that should be merged /-->
    <Exec Command=""$(ILMergeConsolePath)" /out:"$(TargetDestination)/$(AssemblyName).dll" @(InputAssemblies-> '"%(fullpath)"', ' ') /ndebug" />
 </Target>

</Project>

We then do a Release Build in visual studio to generate the dll. We do have plans to automate this some more so that we can do it on our CI without a VIsual Studio project but thats something for the future.

1 Like

Ah that’s neat,
thank you for sharing this :slight_smile: