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 Condition="$(OS) == 'Windows_NT' AND $(EnableGameDebugging) == 'true'">
<!-- enable game debugging -->
<StartAction>Program</StartAction>
<StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram>
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<!--********************************************* <!--*********************************************
** Inject the assembly references and debugging configuration ** Add assembly references
**********************************************--> **********************************************-->
<!-- common -->
<ItemGroup> <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'"> <Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'">
<HintPath>$(GamePath)\smapi-internal\0Harmony.dll</HintPath> <HintPath>$(GamePath)\smapi-internal\0Harmony.dll</HintPath>
<Private>false</Private> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private>
</Reference> </Reference>
</ItemGroup> </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 --> <!-- Windows -->
<PropertyGroup Condition="$(EnableGameDebugging) == 'true'"> <ItemGroup Condition="$(OS) == 'Windows_NT'">
<StartAction>Program</StartAction> <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram> <Private>$(CopyModReferencesToBuildOutput)</Private>
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory> </Reference>
</PropertyGroup> <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
</When> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Otherwise> </Reference>
<!-- references --> <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<ItemGroup> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Reference Include="MonoGame.Framework"> </Reference>
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath> <Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private> <Private>$(CopyModReferencesToBuildOutput)</Private>
<SpecificVersion>false</SpecificVersion> </Reference>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> <Reference Include="Netcode">
</Reference> <HintPath>$(GamePath)\Netcode.dll</HintPath>
<Reference Include="StardewValley"> <Private>$(CopyModReferencesToBuildOutput)</Private>
<HintPath>$(GamePath)\StardewValley.exe</HintPath> </Reference>
<Private>false</Private> <Reference Include="StardewValley.GameData">
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> <HintPath>$(GamePath)\StardewValley.GameData.dll</HintPath>
</Reference> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Reference Include="StardewValley.GameData.MonoGame"> </Reference>
<HintPath>$(GamePath)\StardewValley.GameData.MonoGame.dll</HintPath> </ItemGroup>
<Private>false</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> <!-- Linux/Mac -->
</Reference> <ItemGroup Condition="$(OS) != 'Windows_NT'">
<Reference Include="StardewModdingAPI"> <Reference Include="MonoGame.Framework">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath> <HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
<Private>false</Private> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </Reference>
</Reference> <Reference Include="StardewValley.GameData.MonoGame">
<Reference Include="SMAPI.Toolkit.CoreInterfaces"> <HintPath>$(GamePath)\StardewValley.GameData.MonoGame.dll</HintPath>
<HintPath>$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll</HintPath> <Private>$(CopyModReferencesToBuildOutput)</Private>
<Private>false</Private> </Reference>
<Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </ItemGroup>
</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 ** 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)"