reduce duplication in mod build package

This commit is contained in:
Jesse Plamondon-Willard 2019-06-19 14:22:16 -04:00
parent a54db1b330
commit 62d0b3b322
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 68 additions and 105 deletions

View File

@ -26,133 +26,96 @@
<EnableModZip Condition="'$(EnableModZip)' == ''">true</EnableModZip> <EnableModZip Condition="'$(EnableModZip)' == ''">true</EnableModZip>
<EnableHarmony Condition="'$(EnableModZip)' == ''">false</EnableHarmony> <EnableHarmony Condition="'$(EnableModZip)' == ''">false</EnableHarmony>
<EnableGameDebugging Condition="$(EnableGameDebugging) == ''">true</EnableGameDebugging> <EnableGameDebugging Condition="$(EnableGameDebugging) == ''">true</EnableGameDebugging>
<CopyModReferencesToBuildOutput Condition="'$(CopyModReferencesToBuildOutput)' == ''">false</CopyModReferencesToBuildOutput> <CopyModReferencesToBuildOutput Condition="'$(CopyModReferencesToBuildOutput)' == '' OR ('$(CopyModReferencesToBuildOutput)' != 'true' AND '$(CopyModReferencesToBuildOutput)' != 'false')">false</CopyModReferencesToBuildOutput>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="$(OS) == 'Windows_NT' AND $(EnableGameDebugging) == 'true'">
<!--********************************************* <!-- enable game debugging -->
** Inject the assembly references and debugging configuration
**********************************************-->
<ItemGroup>
<Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'">
<HintPath>$(GamePath)\smapi-internal\0Harmony.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
</ItemGroup>
<Choose>
<When Condition="$(OS) == 'Windows_NT'">
<!-- references -->
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="Netcode">
<HintPath>$(GamePath)\Netcode.dll</HintPath>
<Private>False</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="Stardew Valley">
<HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="StardewValley.GameData">
<HintPath>$(GamePath)\StardewValley.GameData.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="SMAPI.Toolkit.CoreInterfaces">
<HintPath>$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
</ItemGroup>
<!-- launch game for debugging -->
<PropertyGroup Condition="$(EnableGameDebugging) == 'true'">
<StartAction>Program</StartAction> <StartAction>Program</StartAction>
<StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram> <StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram>
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory> <StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
</PropertyGroup> </PropertyGroup>
</When>
<Otherwise>
<!-- references -->
<ItemGroup>
<Reference Include="MonoGame.Framework">
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="StardewValley">
<HintPath>$(GamePath)\StardewValley.exe</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="StardewValley.GameData.MonoGame">
<HintPath>$(GamePath)\StardewValley.GameData.MonoGame.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="SMAPI.Toolkit.CoreInterfaces">
<HintPath>$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
<Reference Include="xTile">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
<!--********************************************* <!--*********************************************
** Deploy mod files & create release zip after build ** Add assembly references
**********************************************-->
<!-- common -->
<ItemGroup>
<Reference Include="$(GameExecutableName)">
<HintPath>$(GamePath)\$(GameExecutableName).exe</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="SMAPI.Toolkit.CoreInterfaces">
<HintPath>$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="xTile">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'">
<HintPath>$(GamePath)\smapi-internal\0Harmony.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
</ItemGroup>
<!-- Windows -->
<ItemGroup Condition="$(OS) == 'Windows_NT'">
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="Netcode">
<HintPath>$(GamePath)\Netcode.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="StardewValley.GameData">
<HintPath>$(GamePath)\StardewValley.GameData.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
</ItemGroup>
<!-- Linux/Mac -->
<ItemGroup Condition="$(OS) != 'Windows_NT'">
<Reference Include="MonoGame.Framework">
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
<Reference Include="StardewValley.GameData.MonoGame">
<HintPath>$(GamePath)\StardewValley.GameData.MonoGame.dll</HintPath>
<Private>$(CopyModReferencesToBuildOutput)</Private>
</Reference>
</ItemGroup>
<!--*********************************************
** Show friendly error for invalid OS or game path
**********************************************--> **********************************************-->
<!-- if game path or OS is invalid, show one user-friendly error instead of a slew of reference errors -->
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
<Error Condition="'$(OS)' != 'OSX' AND '$(OS)' != 'Unix' AND '$(OS)' != 'Windows_NT'" Text="The mod build package doesn't recognise OS type '$(OS)'." /> <Error Condition="'$(OS)' != 'OSX' AND '$(OS)' != 'Unix' AND '$(OS)' != 'Windows_NT'" Text="The mod build package doesn't recognise OS type '$(OS)'." />
<Error Condition="!Exists('$(GamePath)')" Text="The mod build package can't find your game folder. You can specify where to find it; see https://smapi.io/buildmsg/custom-game-path." /> <Error Condition="!Exists('$(GamePath)')" Text="The mod build package can't find your game folder. You can specify where to find it; see https://smapi.io/buildmsg/custom-game-path." />
<Error Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(GamePath)\Stardew Valley.exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain the Stardew Valley.exe file. If this folder is invalid, delete it and the package will autodetect another game install path." /> <Error Condition="!Exists('$(GamePath)\$(GameExecutableName).exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain the $(GameExecutableName) file. If this folder is invalid, delete it and the package will autodetect another game install path." />
<Error Condition="'$(OS)' != 'Windows_NT' AND !Exists('$(GamePath)\StardewValley.exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain the StardewValley.exe file. If this folder is invalid, delete it and the package will autodetect another game install path." />
<Error Condition="!Exists('$(GamePath)\StardewModdingAPI.exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain SMAPI. You need to install SMAPI before building the mod." /> <Error Condition="!Exists('$(GamePath)\StardewModdingAPI.exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain SMAPI. You need to install SMAPI before building the mod." />
</Target> </Target>
<!-- deploy mod files & create release zip -->
<!--*********************************************
** Deploy mod files & create release zip
**********************************************-->
<Target Name="AfterBuild"> <Target Name="AfterBuild">
<DeployModTask <DeployModTask
ModFolderName="$(ModFolderName)" ModFolderName="$(ModFolderName)"