Repository navigation
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
134 lines (112 loc) · 6.64 KB
/
Copy pathDirectory.Build.props
File metadata and controls
134 lines (112 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<Project>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>..\bin\build\$(MSBuildProjectName)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Deterministic>true</Deterministic>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<PackageReference Include="BepInEx.Analyzers" Version="1.*" />
<PackageReference Include="Microsoft.Unity.Analyzers" Version="1.*" />
</ItemGroup>
<PropertyGroup Condition="'$(MSBuildProjectName.IndexOf(.))' != '-1'">
<!--Add constants based on the project name e.g. KK-KKS.Fix_DynamicBones -> KK;KKS;Fix;DynamicBones-->
<DefineConstants>$(MSBuildProjectName.Replace('.',';').Replace('-',';').Replace('_',';'))</DefineConstants>
</PropertyGroup>
<!--Add common nuget packages based on the project name. Must use regex in this way to avoid KK matching KKS, HS matching HS2, etc.-->
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';AI;'))">
<PackageReference Include="ExtensibleSaveFormat.AIGirl" Version="21.0" />
<PackageReference Include="IllusionLibs.AIGirl.AllPackages" Version="*" />
</ItemGroup>
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';HS2;'))">
<PackageReference Include="ExtensibleSaveFormat.HoneySelect2" Version="21.0" />
<PackageReference Include="IllusionLibs.HoneySelect2.AllPackages" Version="*" />
</ItemGroup>
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';KK;'))">
<PackageReference Include="ExtensibleSaveFormat.Koikatu" Version="21.0" />
<PackageReference Include="IllusionLibs.Koikatu.AllPackages" Version="*" />
<PackageReference Include="KoikatuCompatibilityAnalyzer" Version="*" />
</ItemGroup>
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';KKS;'))">
<PackageReference Include="ExtensibleSaveFormat.KoikatsuSunshine" Version="21.0" />
<PackageReference Include="IllusionLibs.KoikatsuSunshine.AllPackages" Version="*" />
<PackageReference Include="IllusionLibs.Koikatu.Vectrosity" Version="*" />
</ItemGroup>
<!--Add old constants to avoid having to change #defines in code-->
<PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';AI;'))">
<DefineConstants>$(DefineConstants);BEPINEX;AISHOUJO</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';HS2;'))">
<DefineConstants>$(DefineConstants);BEPINEX;HONEYSELECT2</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';KK;'))">
<DefineConstants>$(DefineConstants);BEPINEX;KOIKATSU</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(';$(DefineConstants);', ';KKS;'))">
<DefineConstants>$(DefineConstants);BEPINEX;KOIKATSU;SUNSHINE</DefineConstants>
</PropertyGroup>
<!--Delete unnecessary .deps.json file in build output since it's not used in plugins-->
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Delete Files="$(OutputPath)\$(MSBuildProjectName).deps.json" />
</Target>
<!--Do not copy any dlls other than the assembly itself to the build output-->
<Target Name="SkipAllRefs" AfterTargets="ResolveReferences">
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
</Target>
<Target Name="DebugPostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Debug' AND $([MSBuild]::IsOSPlatform('Windows'))">
<!-- pdb2mdb -->
<Exec Command="IF EXIST "$(TargetDir)$(TargetName).pdb" IF EXIST "$(SolutionDir)pdb2mdb.exe" CALL "$(SolutionDir)pdb2mdb.exe" "$(TargetPath)"" ContinueOnError="true" />
<!-- PostBuild.bat with explicit paths -->
<PropertyGroup>
<FullTargetPath>$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).dll</FullTargetPath>
<GameType Condition="'$(GameType)' == ''">$([System.Text.RegularExpressions.Regex]::Match($(MSBuildProjectName), '[^\.]*$'))</GameType>
</PropertyGroup>
<Exec Command='IF EXIST "$(SolutionDir)PostBuild.bat" CALL "$(SolutionDir)PostBuild.bat" "$(FullTargetPath)" "$(GameType)"' ContinueOnError="true" />
<Message Text="PostBuild: TargetPath="$(FullTargetPath)" GameType="$(GameType)"" Importance="high" />
</Target>
<!-- Inline task to get file version from assembly -->
<UsingTask TaskName="GetFileVersion" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<AssemblyPath ParameterType="System.String" Required="true" />
<FileVersion Output="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
FileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(AssemblyPath).FileVersion;
</Code>
</Task>
</UsingTask>
<!-- Create a release zip file (after successful Release build) -->
<Target Name="CreateReleaseZip" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<GetFileVersion AssemblyPath="$(OutputPath)$(AssemblyName).dll">
<Output TaskParameter="FileVersion" PropertyName="FileVersionFromAssembly" />
</GetFileVersion>
<PropertyGroup>
<CopyDir>$(OutputPath)\..\TEMP_COPY_$(MSBuildProjectName)</CopyDir>
<GameType>$([System.Text.RegularExpressions.Regex]::Match($(MSBuildProjectName), '[^\.]*$'))</GameType>
<ZipDir>$(OutputPath)\..\..\out</ZipDir>
<ZipPath>$(ZipDir)\$(GameType)_$(AssemblyName)_v$(FileVersionFromAssembly).zip</ZipPath>
</PropertyGroup>
<ItemGroup>
<BuildFiles Include="$(OutputPath)\**\*"/>
</ItemGroup>
<RemoveDir Directories="$(CopyDir)" />
<Copy DestinationFolder="$(CopyDir)\BepInEx\plugins\%(BuildFiles.RecursiveDir)" SourceFiles="@(BuildFiles)" />
<ItemGroup>
<ZipmodFiles Include="$(CopyDir)\BepInEx\plugins\**\*.zipmod"/>
</ItemGroup>
<Move DestinationFolder="$(CopyDir)\mods\%(ZipmodFiles.RecursiveDir)" SourceFiles="@(ZipmodFiles)" />
<Message Importance="high" Text="Writing release zip to: $(ZipPath)" />
<MakeDir Directories="$(ZipDir)" />
<!-- https://learn.microsoft.com/en-us/visualstudio/msbuild/zipdirectory-task?view=vs-2022 -->
<ZipDirectory SourceDirectory="$(CopyDir)" DestinationFile="$(ZipPath)" Overwrite="true" />
<RemoveDir Directories="$(CopyDir)" />
</Target>
</Project>