Publicize Assemblies - WittleWolfie/OwlcatModdingWiki GitHub Wiki

Publicizing an assembly allows access to private types and members without reflection. This improves performance, simplifies code, and provides type safety.

  • Install the NuGet Package InstallPublicizer
  • Open the project's .csproj file and add
  <Target Name="Publicize" AfterTargets="Clean">
    <ItemGroup>
      <!-- Use $(KingmakerPath)\Kingmaker_Data\Managed\Assembly-CSharp.dll for Kingmaker -->
      <Assemblies Include="$(WrathPath)\Wrath_Data\Managed\Assembly-CSharp.dll" />
    </ItemGroup>

    <PublicizeTask InputAssemblies="@(Assemblies)" OutputDir="$(SolutionDir)lib/" />
  </Target>
  • If you don't have the KingmakerPath and WrathPath environment variables configured you can just use the direct path to the game directory, e.g. C:\Program Files (x86)\Steam\steamapps\common\Pathfinder Second Adventure
  • Go to your project properties and check "Allow unsafe code" under Build AllowUnsafeCode
    • Without this your mod may experience errors or fail to load
  • Edit your project file and add a reference to the publicized assembly, replacing the existing reference if it exists:
  <Reference Include="Assembly-CSharp">
      <HintPath>$(SolutionDir)lib\Assembly-CSharp_public.dll</HintPath>
      <Private>False</Private>
  </Reference>
  • Clean your project
    • In Visual Studio: Build > Clean Solution

Whenever you need to update the game assembly just Clean your project. You should do this whenever a game update is released.

Note: Reference only the publicized assembly or the original assembly. Referencing both results in numerous errors.

⚠️ **GitHub.com Fallback** ⚠️