Skip to content

Instantly share code, notes, and snippets.

@DRKV333
Created August 16, 2020 15:48
Show Gist options
  • Save DRKV333/78d45a3b4e886011c4d23aa66c30bc6d to your computer and use it in GitHub Desktop.
Save DRKV333/78d45a3b4e886011c4d23aa66c30bc6d to your computer and use it in GitHub Desktop.
TModLoader Build System Mockup
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<_TmodOtherFramework Condition="'$(TmodTargetFramework)' == 'XNA'">FNA</_TmodOtherFramework>
<_TmodOtherFramework Condition="'$(TmodTargetFramework)' == 'FNA'">XNA</_TmodOtherFramework>
<_TmodOtherFrameworkProperties>TmodBuildDllOnly=true;TmodTargetFramework=$(_TmodOtherFramework)</_TmodOtherFrameworkProperties>
</PropertyGroup>
<Target Name="TmodWarnNoSystem" BeforeTargets="Build" Condition="$(TmodUseSystemReferences) AND '$(TmodSystemFramework)' == ''">
<Warning Text="TmodUseSystemReferences is set, but no TModLoader installation was found. The build will fall back to packaged references." />
</Target>
<!-- Invoke Clean and Build targets with the other framework recursively. -->
<Target Name="TmodBuildOtherFramework" BeforeTargets="Build">
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="$(_TmodOtherFrameworkProperties)" Targets="Build" />
</Target>
<Target Name="TmodCleanOtherFramework" BeforeTargets="Clean">
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="$(_TmodOtherFrameworkProperties)" Targets="Clean" />
</Target>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="Sdk.props" />
<PropertyGroup>
<AssemblyName>NewBuildSystemTest</AssemblyName>
<TargetFramework>net45</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>latest</LangVersion>
<!--><TmodUseSystemReferences>true</TmodUseSystemReferences><!-->
</PropertyGroup>
<Import Project="Sdk.targets" />
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Determine the "primary" build target for the project based on platform.
The project can also read this if it needs to something different based on the framework. -->
<PropertyGroup>
<TmodTargetFramework Condition="'$(TmodTargetFramework)' == '' AND $([MSBuild]::IsOsPlatform('Windows'))">XNA</TmodTargetFramework>
<TmodTargetFramework Conditiosn="'$(TmodTargetFramework)' == ''">FNA</TmodTargetFramework>
</PropertyGroup>
<!-- Detect TModLoader paths here, in case the project needs them for something. -->
<PropertyGroup>
<TmodSavePath Condition="'$(tmodSavePath)' == '' AND $([MSBuild]::IsOsPlatform('Windows'))">$(registry:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders@Personal)\My Games\Terraria\ModLoader</TmodSavePath>
<TmodSavePath Condition="'$(tmodSavePath)' == '' AND $([MSBuild]::IsOsPlatform('Linux')) AND '$(XDG_DATA_HOME)' != ''">$(XDG_DATA_HOME)/.local/share/Terraria/ModLoader</TmodSavePath>
<TmodSavePath Condition="'$(tmodSavePath)' == '' AND $([MSBuild]::IsOsPlatform('Linux'))">$(HOME)/.local/share/Terraria/ModLoader</TmodSavePath>
<TmodSavePath Condition="'$(tmodSavePath)' == '' AND $([MSBuild]::IsOsPlatform('OSX'))">$(HOME)/Library/Application Support/Terraria/ModLoader</TmodSavePath>
<TmodReferenceTargetPath Condition="'$(TmodReferenceTargetPath)' == ''">$(tmodSavePath)/References/tModLoader.targets</TmodReferenceTargetPath>
</PropertyGroup>
<!-- This can be set to true by the project to force the use of the installed references. -->
<PropertyGroup>
<TmodUseSystemReferences Condition="'$(TmodUseSystemReferences)' == ''">false</TmodUseSystemReferences>
</PropertyGroup>
<!-- Detect the version of the installed references. ('XNA', 'FNA', or '' for none detected) -->
<PropertyGroup Condition="Exists('$(TmodReferenceTargetPath)')">
<TmodSystemFramework Condition="$([MSBuild]::IsOsPlatform('Windows'))">XNA</TmodSystemFramework>
<TmodSystemFramework Condition="'$(TmodTargetFramework)' == ''">FNA</TmodSystemFramework>
</PropertyGroup>
<!-- Different output folders for the different frameworks. -->
<PropertyGroup>
<OutputPath>bin/$(Configuration)/$(TmodTargetFramework)/</OutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)/$(TmodTargetFramework)/</IntermediateOutputPath>
</PropertyGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<_TmodBuildWithSystem>false</_TmodBuildWithSystem>
<_TmodBuildWithSystem Condition="$(TmodUseSystemReferences) AND '$(TmodTargetFramework)' == '$(TmodSystemFramework)'">true</_TmodBuildWithSystem>
</PropertyGroup>
<!-- Import the installed references. -->
<Import Condition="$(_TmodBuildWithSystem)" Project="$(tmodSavePath)/References/tModLoader.targets" />
<!-- Add XNA references from the NuGet package. -->
<ItemGroup Condition="!$(_TmodBuildWithSystem) AND '$(TmodTargetFramework)' == 'XNA'">
<Reference Include="DummyXNA">
<HintPath>./DummyXNA.dll</HintPath>
</Reference>
</ItemGroup>
<!-- Add FNA references from the NuGet package. -->
<ItemGroup Condition="!$(_TmodBuildWithSystem) AND '$(TmodTargetFramework)' == 'FNA'">
<Reference Include="DummyFNA">
<HintPath>./DummyFNA.dll</HintPath>
</Reference>
</ItemGroup>
<!-- Import the build target conditionally, to avoid circular dependency graph. -->
<Import Condition="'$(TmodBuildDllOnly)' != 'true'" Project="Build.targets" />
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment