Skip to content

Commit

Permalink
Migrate MTGOSDK.Ref project (#17)
Browse files Browse the repository at this point in the history
Moves MTGOSDK.Ref references to MTGOSDK.MSBuild; resolves #16.
  • Loading branch information
Qonfused authored Apr 7, 2024
1 parent deba5ac commit cad9736
Show file tree
Hide file tree
Showing 21 changed files with 999 additions and 228 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ jobs:
if: steps.nuget-cache.outputs.cache-hit != 'true'
run: nuget restore SDK.sln ${{ env.NUGET_DEFAULTS }}

# Build MTGO reference assemblies
- name: Build Reference Assemblies
run: msbuild Ref.sln /t:Build ${{ env.MSBUILD_DEFAULTS }}
# Build the SDK
- name: Build SDK Solution
run: msbuild SDK.sln /t:Build ${{ env.MSBUILD_DEFAULTS }}
Expand Down
5 changes: 2 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<!-- This file is used to provide missing properties for the msbuild cli. -->
<Project>

<!-- Project Directories -->
<PropertyGroup>
<!-- Project Directories -->
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<DistDir>$(SolutionDir)\dist</DistDir>
<!-- User Directories -->
<LocalDir>$([MSBuild]::NormalizeDirectory($(AppData)\..\Local))</LocalDir>
</PropertyGroup>

<PropertyGroup>
<UseFullSDKPaths>true</UseFullSDKPaths>
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
</PropertyGroup>

Expand Down
19 changes: 11 additions & 8 deletions MTGOSDK.MSBuild/MTGOSDK.MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<ItemGroup Label="Package">
<!--
These lines pack the build props/targets files to the `build` folder in
the generated package. By convention, the .NET SDK will look for
build\<Package Id>.props and build\<Package Id>.targets for automatic
inclusion in the build.
These lines pack the build props/targets files to the `build` and
`buildTransitive` folders in the generated package. By convention, the
.NET SDK will look for build\<packageId>.props and build\<packageId>.targets
for automatic inclusion in the build.
The `build` folder is for the props/targets files that are directly
imported by the consuming project. The `buildTransitive` folder is for
the props/targets files that are imported by any upstream consumers.
-->
<Content Include="build\MTGOSDK.MSBuild.props" PackagePath="build\" />
<Content Include="build\MTGOSDK.MSBuild.targets" PackagePath="build\" />
<None Include="build\**" Pack="true" PackagePath="build;buildTransitive" />
</ItemGroup>

<ItemGroup>
<ItemGroup Label="Dependencies">
<!--
These dependencies are provided by MSBuild at runtime, so we don't need to
include them in the package.
Expand Down
5 changes: 3 additions & 2 deletions MTGOSDK.MSBuild/build/MTGOSDK.MSBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

<!-- These directories get expanded to full paths automatically on build -->
<PropertyGroup>
<MTGOAppDir>$(LocalDir)Apps\2.0\*.*\**\mtgo..tion_*</MTGOAppDir>
<MTGODataDir>$(LocalDir)Apps\2.0\Data\**\mtgo..tion_\Data</MTGODataDir>
<LocalAppDir>$([MSBuild]::NormalizeDirectory($(AppData)\..\Local))</LocalAppDir>
<MTGOAppDir>$(LocalAppDir)Apps\2.0\*.*\**\mtgo..tion_*</MTGOAppDir>
<MTGODataDir>$(LocalAppDir)Apps\2.0\Data\**\mtgo..tion_\Data</MTGODataDir>
</PropertyGroup>

<!-- These directories are automatically built for internal use of the SDK -->
Expand Down
26 changes: 14 additions & 12 deletions MTGOSDK.MSBuild/build/MTGOSDK.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@
TaskName="GenerateReferenceAssemblies"
TaskFactory="TaskHostFactory" />

<ItemGroup>
<!--
Add a `ProjectReference` to ensure that the task is built before being
called in a consuming project. This is necessary because the task assembly
is not referenced to be built by default, which will fail the build.
-->
<ProjectReference Include="..\MTGOSDK.MSBuild\MTGOSDK.MSBuild.csproj"
ReferenceOutputAssembly="false" />
</ItemGroup>

<Target Name="GenerateReferenceAssemblies"
BeforeTargets="CoreCompile"
DependsOnTargets="ResolveProjectReferences;ResolveAssemblyReferences">
BeforeTargets="ResolveAssemblyReferences">
<!--
Extract the MTGO installation directory paths, or create a temporary
extraction directory if no existing MTGO installation could be found.
Expand Down Expand Up @@ -70,6 +59,19 @@
<Message Text="MTGOSDK.MSBuild: Reference assemblies are located at $(_MTGOSDK_Refs)"
Importance="high"
Condition="'$(HasSkipped)' != 'true'" />

<!-- Include reference assemblies in search path of a consuming project -->
<PropertyGroup>
<AssemblySearchPaths>$(AssemblySearchPaths);$(_MTGOSDK_Refs)</AssemblySearchPaths>
</PropertyGroup>

<!-- Notify if the task has skipped generating reference assemblies -->
<Message Text="MTGOSDK.MSBuild: Finished bootstrapping MTGOSDK reference assemblies."
Importance="high"
Condition="Exists('$(_MTGOSDK_Refs)\MTGO.exe')" />
<Message Text="MTGOSDK.MSBuild: Failed to bootstrap MTGOSDK reference assemblies."
Importance="high"
Condition="!Exists('$(_MTGOSDK_Refs)\MTGO.exe')" />
</Target>

</Project>
35 changes: 0 additions & 35 deletions MTGOSDK.Ref/MTGOSDK.Ref.csproj

This file was deleted.

27 changes: 0 additions & 27 deletions MTGOSDK.Ref/packages.lock.json

This file was deleted.

1 change: 0 additions & 1 deletion MTGOSDK.Win32/MTGOSDK.Win32.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

</Project>
56 changes: 36 additions & 20 deletions MTGOSDK/MTGOSDK.ref.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,48 @@
<NoWarn>$(NoWarn);NU1702;MSB3277;</NoWarn>
<!-- Used for referencing WPF assemblies at runtime (w/ reflection) -->
<UseWPF>true</UseWPF>
<!-- Whether to include reference assemblies as part of the package. -->
<UseRef>true</UseRef>
<!-- <UseRef>false</UseRef>
<UseRef Condition="'$(UseFullSDKPaths)' == 'false'">true</UseRef> -->
</PropertyGroup>

<!--
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" />
<!--
Add a `ProjectReference` to ensure that the task is built before being
called in a consuming project. This is necessary because the task assembly
is not referenced to be built by default, which will fail the build.
-->
<ProjectReference Include="..\MTGOSDK.MSBuild\MTGOSDK.MSBuild.csproj"
PrivateAssets="all" />
<!--
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.
We optionally disable copying reference assemblies to the output directory
when specifying `Private="false"`. This tells the compiler that the GAC
will provide the assemblies instead. We do this to only use the reference
assemblies for compilation, and not include them as part of the package.
Instead, consumers of the SDK will generate their own reference assemblies
using transitive build targets provided by the `MTGOSDK.MSBuild` 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" />
<Reference Include="Core" Private="$(UseRef)" />
<Reference Include="FlsClient" Private="$(UseRef)" />
<Reference Include="MTGOEnumStruct" Private="$(UseRef)" />
<Reference Include="WotC.MtGO.Client.Common" Private="$(UseRef)" />
<Reference Include="WotC.MtGO.Client.Model.Chat" Private="$(UseRef)" />
<Reference Include="WotC.MtGO.Client.Model.Core" Private="$(UseRef)" />
<Reference Include="WotC.MtGO.Client.Model.Reference" Private="$(UseRef)" />
</ItemGroup>

<!--
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"
Condition="'$(UseFullSDKPaths)' == 'true'" />
<Import Project="..\MTGOSDK.MSBuild\build\MTGOSDK.MSBuild.targets"
Condition="'$(UseFullSDKPaths)' == 'true'" />

</Project>
Loading

0 comments on commit cad9736

Please sign in to comment.