-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
111 lines (100 loc) · 5.17 KB
/
Directory.Build.targets
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
<!--
https://github.com/lc-sigurd/Sigurd/tree/87c45e93351a16d39223a524305a96eb03a8a472/
The Sigurd Team licenses this file to Lordfirespeed under the LGPL-3.0-OR-LATER license.
Lordfirespeed licenses this file to you under the LGPL-3.0-OR-LATER license.
-->
<Project>
<Import Project="$(MSBuildThisFileDirectory)/MSBuildTasks/MSBuildTasks.targets" Condition="$(MSBuildProjectName) != 'MSBuildTasks'"/>
<!-- prevent referenced assemblies from being copied to output folders -->
<Target Name="ClearReferenceCopyLocalPaths" AfterTargets="ResolveAssemblyReferences" Condition="$(ClearCopyLocalPaths) == 'true'">
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"/>
</ItemGroup>
</Target>
<Target Name="SetPluginVersion" BeforeTargets="AddGeneratedFile" DependsOnTargets="MinVer">
<Message Importance="high" Text="MinVer version is $(MinVerVersion)"/>
<PropertyGroup>
<PlainVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</PlainVersion>
<BepInExPluginVersion>$(PlainVersion)</BepInExPluginVersion>
</PropertyGroup>
</Target>
<!-- https://github.com/BepInEx/BepInEx.Templates/blob/9d628c67de0a84337f38f755eeb6646696ae8423/BepInEx.PluginInfoProps/BepInEx.PluginInfoProps.props -->
<!-- BepInEx.PluginInfoProps Copyright (c) 2021 BepInEx -->
<Target
Name="AddGeneratedFile"
BeforeTargets="BeforeCompile;CoreCompile"
Condition="$(HasBepInPlugin) == 'true'"
Inputs="$(MSBuildAllProjects)"
Outputs="$(IntermediateOutputPath)MyPluginInfo.cs"
>
<PropertyGroup>
<BepInExPluginGuid Condition="'$(BepInExPluginGuid)' == ''">$(AssemblyName)</BepInExPluginGuid>
<BepInExPluginName Condition="'$(BepInExPluginName)' == ''">$(Product)</BepInExPluginName>
<BepInExPluginVersion Condition="'$(BepInExPluginVersion)' == ''">$(Version)</BepInExPluginVersion>
<GeneratedText><![CDATA[
namespace $(RootNamespace)%3B
#pragma warning disable 1591
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "$(BepInExPluginGuid)"%3B
public const string PLUGIN_NAME = "$(BepInExPluginName)"%3B
public const string PLUGIN_VERSION = "$(BepInExPluginVersion)"%3B
}
#pragma warning restore 1591
]]></GeneratedText>
<GeneratedFilePath>$(IntermediateOutputPath)MyPluginInfo.cs</GeneratedFilePath>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(GeneratedFilePath)" />
<FileWrites Include="$(GeneratedFilePath)" />
</ItemGroup>
<WriteLinesToFile Lines="$(GeneratedText)" File="$(GeneratedFilePath)" WriteOnlyWhenDifferent="true" Overwrite="true" />
</Target>
<Target
Name="NetcodePatch"
AfterTargets="PostBuildEvent"
Condition="$(RequiresNetcodePatch) == 'true'"
>
<Exec Command="dotnet netcode-patch "$(TargetPath)" @(ReferencePathWithRefAssemblies->'"%(Identity)"', ' ')"/>
</Target>
<Target
Name="PatchThunderstoreMetadata"
DependsOnTargets="SetPluginVersion"
Condition="$(IsThunderstorePackable) == 'true'"
>
<PropertyGroup>
<_ConfigurationFileOutputPath>$(ProjectDir)assets/thunderstore.toml.user</_ConfigurationFileOutputPath>
</PropertyGroup>
<PatchThunderstoreMetadata
ConfigurationFileOutputPath="$(_ConfigurationFileOutputPath)"
PackageNamespace="$(ThunderstoreNamespace)"
PackageName="$(ThunderstoreName)"
PackageWebsiteUrl="$(ThunderstoreWebsiteUrl)"
PackageVersion="$(PlainVersion)"
PackageDescription="$(ThunderstoreDescription)"
PackageContainsNsfwContent="false"
PackageDependencies="@(ThunderstoreDependency)"
BuildReadmePath="$(ThunderstoreReadmePath)"
BuildIconPath="$(ThunderstoreIconPath)"
BuildOutDir="$(ThunderstoreOutDir)"
BuildCopyPaths="@(ThunderstoreBuildCopyPath)"
PublishCommunities="@(ThunderstorePublishCommunity)"
/>
</Target>
<Target
Name="ThunderstorePack"
DependsOnTargets="NetcodePatch;SetPluginVersion;PatchThunderstoreMetadata"
AfterTargets="PostBuildEvent"
Condition="$(TargetFramework) == 'netstandard2.1' and $(IsThunderstorePackable) == 'true' and $(Configuration) == 'Release'"
>
<MakeDir Directories="$(ProjectDir)assets/bundles" Condition="!Exists('$(ProjectDir)assets/bundles')"/>
<Exec Command="dotnet tcli build --config-path $(ProjectDir)assets/thunderstore.toml.user --package-version $(PlainVersion)"/>
<ItemGroup>
<FilesToRename Include="$(ProjectDir)dist/*-$(PlainVersion).zip"/>
</ItemGroup>
<Move SourceFiles="@(FilesToRename)" DestinationFiles="@(FilesToRename -> Replace($(PlainVersion), $(MinVerVersion)))"/>
</Target>
<Target Name="ThunderstorePublish" DependsOnTargets="SetPluginVersion" Condition="$(IsThunderstorePackable) == 'true'">
<Exec Command="dotnet tcli publish --config-path $(ProjectDir)assets/thunderstore.toml.user --file $(ProjectDir)dist/*-$(MinVerVersion).zip"/>
</Target>
</Project>