videre-project / MTGOSDK

A software development kit (SDK) for inspecting and interacting with the Magic: The Gathering Online (MTGO) client.
Apache License 2.0
3 stars 0 forks source link

Merge MTGOSDK.MSBuild and MTGOSDK.Ref projects #16

Closed Qonfused closed 3 months ago

Qonfused commented 3 months ago

Within the MTGOSDK.Ref project, a new target should include the built reference assemblies for consumption through the library (without needing explicit references for each DLL):

<!-- Packaging assemblies for NuGet publishing -->
<ItemGroup>
  <Content Include="$(_MTGOSDK_Refs)\*.dll">
    <Pack>true</Pack>
    <PackagePath>lib\$(TargetFramework)</PackagePath>
  </Content>
</ItemGroup>
<!-- Importing MTGOSDK.Ref in a consuming project -->
<PackageReference Include="VidereProject.MTGOSDK.Ref"
                  Version="1.0.0" />

Versus the current setup, which requires bootstrapping the MTGOSDK.Ref project with MTGOSDK.MSBuild (internal project):

<!--
  Bootstrap the MTGOSDK.Ref project to generate reference assemblies for
  the current MTGO version. Due to the way that MSBuild works, this must
  import the MTGOSDK.MSBuild.props file before referencing the project.
-->
<Import Project="..\MTGOSDK.MSBuild\build\MTGOSDK.MSBuild.props" />
<PropertyGroup>
  <MTGOSDK_Refs>$(_MTGOSDK_Refs)\3.4.*.*</MTGOSDK_Refs>
</PropertyGroup>
<ItemGroup>
  <ProjectReference Include="..\MTGOSDK.Ref\MTGOSDK.Ref.csproj"
                    ReferenceOutputAssembly="false" />
  <!--
    Include reference assemblies to compile against the current MTGO version.
    Note that the '_MTGOSDK_Refs' path does not reference the updated version
    subpath as it is only evaluated after building the MTGOSDK.Ref project.
  -->
  <Reference Include="$(MTGOSDK_Refs)\Core.dll" />
  <Reference Include="$(MTGOSDK_Refs)\FlsClient.dll" />
  <Reference Include="$(MTGOSDK_Refs)\MTGOEnumStruct.dll" />
  <Reference Include="$(MTGOSDK_Refs)\WotC.MtGO.Client.Common.dll" />
  <Reference Include="$(MTGOSDK_Refs)\WotC.MtGO.Client.Model.Chat.dll" />
  <Reference Include="$(MTGOSDK_Refs)\WotC.MtGO.Client.Model.Core.dll" />
  <Reference Include="$(MTGOSDK_Refs)\WotC.MtGO.Client.Model.Reference.dll" />
</ItemGroup>
Qonfused commented 3 months ago

Should look into packaging properties/targets under a buildTransitive folder in the NuGet package (reference).

Bootstrapping MTGO reference assembly generation at project reference and including the directory paths dynamically would avoid needing to publish the reference assemblies in the package. Instead, they can be generated at restore/build-time.

Below is an example of how this can be used in the MTGOSDK library (as well as in consumer applications):

<ItemGroup>
  <!--
    Import the MTGOSDK.Ref project to generate reference assemblies for the
    current MTGO version. Consumers of MTGOSDK should not need to reference
    this project directly as it is imported transitively.
  -->
  <ProjectReference Include="..\MTGOSDK.Ref\MTGOSDK.Ref.csproj"
                    ReferenceOutputAssembly="false" />
  <!--
    Include reference assemblies to compile against the current MTGO version.
  -->
  <Reference Include="Core" />
  <Reference Include="FlsClient" />
  <Reference Include="MTGOEnumStruct" />
  <Reference Include="WotC.MtGO.Client.Common" />
  <Reference Include="WotC.MtGO.Client.Model.Chat" />
  <Reference Include="WotC.MtGO.Client.Model.Core" />
  <Reference Include="WotC.MtGO.Client.Model.Reference" />
</ItemGroup>