mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-16 09:19:37 -06:00
initial tinkerings
This commit is contained in:
71
Directory.Build.targets
Normal file
71
Directory.Build.targets
Normal file
@@ -0,0 +1,71 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<!-- Try to find the directory on our own -->
|
||||
<GameManagedDir Condition="'$(GameManagedDir)' == ''">$([System.IO.Directory]::GetDirectories(`$(GameDir)`, `*_Data`)[0])\Managed</GameManagedDir>
|
||||
|
||||
<!-- Copy the mod to the game directory -->
|
||||
<GameModDir Condition="'$(GameModDir)' == ''">$(GameDir)/Mods/$(AssemblyName)</GameModDir>
|
||||
<OutDir Condition="'$(Configuration)' == 'Debug'">$(GameModDir)/</OutDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Replace the default version if something was set for it -->
|
||||
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
||||
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
||||
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
||||
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
|
||||
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Reference the .dll/.exes specified with GameAssembly elements-->
|
||||
<Reference Include="@(GameAssembly)">
|
||||
<HintPath Condition="Exists('$(GameManagedDir)\%(Identity).dll')">$(GameManagedDir)\%(Identity).dll</HintPath>
|
||||
<HintPath Condition="Exists('$(GameManagedDir)\%(Identity).exe')">$(GameManagedDir)\%(Identity).exe</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Publish the mod as a neat zip file -->
|
||||
<Target Name="PrepareForPublishing" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
|
||||
<!-- Replace $(AssemblyVersion) with the actual version -->
|
||||
<Exec Command="powershell -Command "(Get-Content '$(OutputPath)Definition.json') -replace '\$\(AssemblyVersion\)', '$(AssemblyVersion)' | Set-Content '$(OutputPath)Definition.json'"" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ModsDirectory>$(OutputPath)/Mods</ModsDirectory>
|
||||
<ModDirectory>$(ModsDirectory)/$(AssemblyName)</ModDirectory>
|
||||
|
||||
<!-- Folder we'll put the published zips into -->
|
||||
<PublishPath>../bin</PublishPath>
|
||||
<ZipName>$(PublishPath)/$(AssemblyName)_$(AssemblyVersion).zip</ZipName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Assure the output path exists -->
|
||||
<MakeDir Directories="$(PublishPath)" />
|
||||
|
||||
<!-- Remove the old Mods directory, and Zips file if any is lying around -->
|
||||
<ItemGroup>
|
||||
<OldZips Include="$(PublishPath)/$(AssemblyName)_*.zip" />
|
||||
</ItemGroup>
|
||||
|
||||
<RemoveDir Directories="$(ModsDirectory)" ContinueOnError="true" />
|
||||
<Delete Files="@(OldZips)" />
|
||||
|
||||
<!-- Create the Mods directory again -->
|
||||
<MakeDir Directories="$(ModDirectory)" />
|
||||
|
||||
<!-- Move all files to the right folder -->
|
||||
<ItemGroup>
|
||||
<OutputFiles Include="$(OutputPath)/**/*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(ModDirectory)" />
|
||||
|
||||
<!-- Zip it up -->
|
||||
<Exec Command="powershell -Command "Compress-Archive -Path '$(ModsDirectory)' -Destination '$(ZipName)'"" />
|
||||
|
||||
<!-- Move them to the game directory -->
|
||||
<Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(GameModDir)" />
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user