1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-22 13:03:23 +08:00
Files
DSP_Mods/Directory.Build.targets

110 lines
5.6 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
UpdateGameDlls target: locates the Dyson Sphere Program installation via the
Steam registry and libraryfolders.vdf, then uses assembly-publicizer to
refresh AssemblyFromGame/ whenever the game DLLs are newer than the local copies.
Runs automatically before every build (BeforeTargets="BeforeBuild") and can
also be invoked explicitly:
dotnet build -t:UpdateGameDlls
Requires assembly-publicizer on PATH or in %USERPROFILE%\.dotnet\tools\:
dotnet tool install -g BepInEx.AssemblyPublicizer.Cli
-->
<Target Name="UpdateGameDlls" BeforeTargets="BeforeBuild">
<Exec
Command="powershell.exe -NoProfile -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)UpdateGameDlls.ps1&quot; -ProjectRoot &quot;$(MSBuildThisFileDirectory.TrimEnd('\\/'))&quot;"
ConsoleToMSBuild="true"
IgnoreExitCode="false"
WorkingDirectory="$(MSBuildThisFileDirectory)" />
</Target>
<!--
ZipMod target: assembles a Thunderstore-ready zip under package/.
Run explicitly with: dotnet build -t:ZipMod -c Release
It does NOT run automatically on every build.
"Pack" is reserved by the .NET SDK for NuGet packaging, so this target
uses the name "ZipMod" to avoid conflict.
Per-project customisation properties (set in the project's PropertyGroup):
PackHasChangelog set to 'true' to include CHANGELOG.md in the zip
PackUsePluginsLayout set to 'true' for the plugins/patchers folder layout
(used by Dustbin and LabOpt)
Simple layout zips:
<AssemblyName>.dll icon.png manifest.json README.md [CHANGELOG.md]
plugins/patchers layout zips:
plugins/ patchers/ icon.png manifest.json README.md [CHANGELOG.md]
-->
<Target Name="ZipMod" DependsOnTargets="Build" Condition="'$(PackPreloaderTargetDir)' == ''">
<PropertyGroup>
<_PackageDir>$(MSBuildProjectDirectory)\package</_PackageDir>
<_StagingDir>$(MSBuildProjectDirectory)\obj\pack-staging</_StagingDir>
<_ZipPath>$(_PackageDir)\$(ProjectName)-$(Version).zip</_ZipPath>
</PropertyGroup>
<!-- ── plugins/patchers layout: copy DLL into package/plugins/ first ── -->
<MakeDir Directories="$(_PackageDir)\plugins"
Condition="'$(PackUsePluginsLayout)' == 'true'" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(_PackageDir)\plugins"
Condition="'$(PackUsePluginsLayout)' == 'true'" />
<!-- Collect loose root files (common to both layouts) -->
<ItemGroup>
<_PackRootFiles Include="$(_PackageDir)\icon.png" />
<_PackRootFiles Include="$(_PackageDir)\manifest.json" />
<_PackRootFiles Include="$(MSBuildProjectDirectory)\README.md" />
<_PackRootFiles Include="$(MSBuildProjectDirectory)\CHANGELOG.md"
Condition="'$(PackHasChangelog)' == 'true'" />
<!-- Simple layout: also include the DLL itself at the root -->
<_PackRootFiles Include="$(TargetPath)"
Condition="'$(PackUsePluginsLayout)' != 'true'" />
</ItemGroup>
<!-- Prepare staging directory -->
<RemoveDir Directories="$(_StagingDir)" />
<MakeDir Directories="$(_StagingDir)" />
<!-- Copy loose root files into staging root -->
<Copy SourceFiles="@(_PackRootFiles)" DestinationFolder="$(_StagingDir)" />
<!-- plugins/patchers layout: copy sub-folders into staging (preserve structure) -->
<ItemGroup Condition="'$(PackUsePluginsLayout)' == 'true'">
<_PluginFiles Include="$(_PackageDir)\plugins\**\*" />
<_PatcherFiles Include="$(_PackageDir)\patchers\**\*" />
</ItemGroup>
<Copy SourceFiles="@(_PluginFiles)"
DestinationFiles="@(_PluginFiles->'$(_StagingDir)\plugins\%(RecursiveDir)%(Filename)%(Extension)')"
Condition="'$(PackUsePluginsLayout)' == 'true'" />
<Copy SourceFiles="@(_PatcherFiles)"
DestinationFiles="@(_PatcherFiles->'$(_StagingDir)\patchers\%(RecursiveDir)%(Filename)%(Extension)')"
Condition="'$(PackUsePluginsLayout)' == 'true'" />
<!-- Delete previous zip if present -->
<Delete Files="$(_ZipPath)" Condition="Exists('$(_ZipPath)')" />
<!-- Create zip using powershell.exe (explicit executable works from any shell) -->
<Exec Command="powershell.exe -NoProfile -Command &quot;Compress-Archive -Path '$(_StagingDir)\*' -DestinationPath '$(_ZipPath)'&quot;" />
<!-- Clean up staging directory -->
<RemoveDir Directories="$(_StagingDir)" />
<Message Text="ZipMod: created $(_ZipPath)" Importance="high" />
</Target>
<!-- ── Preloader helper target ────────────────────────────────────────────
Preloader projects (DustbinPreloader, LabOptPreloader) call this to
copy their output DLL into the sibling main mod's patchers/ folder.
Set PackPreloaderTargetDir in the preloader's csproj, e.g.:
<PackPreloaderTargetDir>..\Dustbin\package\patchers</PackPreloaderTargetDir>
──────────────────────────────────────────────────────────────────────── -->
<Target Name="CopyToParentPackage" DependsOnTargets="Build"
Condition="'$(PackPreloaderTargetDir)' != ''">
<MakeDir Directories="$(PackPreloaderTargetDir)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PackPreloaderTargetDir)" />
<Message Text="CopyToParentPackage: copied $(TargetFileName) to $(PackPreloaderTargetDir)" Importance="high" />
</Target>
</Project>