Skip to content

MSBuild

wwwDayDream edited this page May 9, 2024 · 1 revision

CessilCellsCeaChells.MSBuild Tool

Allows you to access most created members without using System.Reflection, but requires the creation of an additional (barebones) project.

Installation

  • Install the CessilCellsCeaChells.MSBuild NuGet package into your NET Standard 2.1+ or NET Framework 3.5+ Project.

  • Create a secondary project of the same framework as your primary project.

  • In that project reference the CessilCellsCeaChells NuGet package, as well as any additional packages, you wish to patch.

  • Add your desired [Requires...] attributes in the newly created project. Note: All classes within this project shouldn't reference the parent project.

  • Finally, reference the new project by adding a Project Reference in your original project.

The Tricky Part

You need to edit your primary projects raw .csproj to add some tags to the xml of the references you're utilizing. CessilCellsCeaChells.MSBuild looks for MergeFrom="true" or MergeInto="true" on your projects references, which must be added manually.

  • First find your <ProjectReference> tag inside your csproj and add the MergeFrom="true" like below
<Project Sdk="Microsoft.NET.Sdk">
    ...
    <ItemGroup>
        ...
        <ProjectReference Include="..\Alt.Project.Name\Alt.Project.Name.csproj" MergeFrom="true" />
    </ItemGroup>
    ...
</Project>
  • Finally, you'll add a MergeInto="true" to any of the references for the games dll's. Below is an example of adding the tag to the ContentWarning.GameLibs.Steam NuGet reference.
<Project Sdk="Microsoft.NET.Sdk">
    ...
    <ItemGroup>
        ...
        <PackageReference Include="ContentWarning.GameLibs.Steam" Version="*-*" Publicize="true" MergeInto="true" />
    </ItemGroup>
    ...
</Project>

Note: The above example shows it working along-side BepInEx.AssemblyPublicizer.MSBuild which mitigates fields only being private.