-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Directory.Build.targets
124 lines (124 loc) · 9.89 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
112
113
114
115
116
117
118
119
120
121
122
123
124
<?xml version="1.0" encoding="utf-8"?>
<!-- This file contains the build tasks and targets for verifying the manifest, zipping Release builds,
and copying the plugin to to your Beat Saber folder. Only edit this if you know what you are doing. -->
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildTargetsVersion>2.0</BuildTargetsVersion>
<!--Set this to true if you edit this file to prevent automatic updates-->
<BuildTargetsModified>true</BuildTargetsModified>
<!--Output assembly path without extension-->
<OutputAssemblyName>$(OutputPath)$(AssemblyName)</OutputAssemblyName>
<ReleaseName>$(AssemblyName)-$(Version)</ReleaseName>
<!--Path to folder to be zipped. Needs to be relative to the project directory to work without changes to the 'BuildForCI' target.-->
<ArtifactDestination>$(OutputPath)Final</ArtifactDestination>
<ErrorOnMismatchedVersions Condition="'$(Configuration)' == 'Release' OR '$(Configuration)' == 'Release-BeatSaber'">True</ErrorOnMismatchedVersions>
</PropertyGroup>
<!--Build Targets-->
<!--Displays a warning if BeatSaberModdingTools.Tasks is not installed.-->
<Target Name="CheckBSMTInstalled" AfterTargets="BeforeBuild" Condition="'$(BSMTTaskAssembly)' == ''">
<Error Text="The BeatSaberModdingTools.Tasks nuget package doesn't seem to be installed, advanced build targets will not work." ContinueOnError="true" />
</Target>
<Target Name="SetFullReleaseInfo" AfterTargets="CheckBSMTInstalled" Condition="'$(BSMTTaskAssembly)' != '' AND '$(NCRUNCH)' != '1'">
<Message Text="DisableCopyArtifacts: '$(DisableCopyArtifacts)'" Importance="high" />
<Message Text="DisableZipRelease: '$(DisableZipRelease)'" Importance="high" />
<Message Text="DisableCopyToPlugins: '$(DisableCopyToPlugins)'" Importance="high" />
<Message Text="ContinuousIntegrationBuild: '$(ContinuousIntegrationBuild)'" Importance="high" />
<PropertyGroup Condition="'$(BeatSaberRelease)' == 'True'">
<ReleaseName>$(AssemblyName)-$(Version)-bs$(GameVersion)-$(CommitHash)</ReleaseName>
<ManifestPath>$(ProjectDir)$(OutputPath)$(AssemblyName).manifest</ManifestPath>
</PropertyGroup>
<PropertyGroup Condition="'$(BeatSaberRelease)' != 'True'">
<ReleaseName>$(AssemblyName)-$(Version)-$(CommitHash)</ReleaseName>
</PropertyGroup>
<Message Text="Beat Saber Release: PluginVersion: $(PluginVersion), AssemblyVersion: $(Version), GameVersion: $(GameVersion)"
Importance="high" Condition="'$(BeatSaberRelease)' == 'True'"/>
<Message Text="Lib Release: $(Version)" Importance="high" Condition="'$(BeatSaberRelease)' != 'True'"/>
<GenerateManifest Id="$(AssemblyName)" Name="$(AssemblyName)" Version="$(Version)" GameVersion="$(GameVersion)"
Author="$(Authors)" Description="$(Description)"
DependsOn="@(Dependency)" Files="@(RequiredFile)" ProjectHome="$(PackageProjectUrl)"
ProjectSource="$(RepositoryUrl)" Donate="$(DonationUrl)" RequiresBsipa="False"
TargetPath="$(ManifestPath)" BaseManifestPath="$(ProjectDir)manifest.json" Condition="'$(BeatSaberRelease)' == 'True'" />
<Message Text="Manifest generated to '$(ManifestPath)'" Importance="high"/>
</Target>
<Target Name="CopyBeatSaberArtifacts" AfterTargets="Build" Condition="'$(BeatSaberRelease)' == 'True' AND '$(DisableCopyArtifacts)' != 'True'">
<Message Text="Copying Beat Saber artifacts to '$(ArtifactDestination)'" Importance="high"/>
<Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFiles="$(ArtifactDestination)\Libs\$(AssemblyName).dll" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).xml" DestinationFiles="$(ArtifactDestination)\Libs\$(AssemblyName).xml" />
<Copy SourceFiles="$(ManifestPath)" DestinationFiles="$(ArtifactDestination)\Plugins\$(AssemblyName).manifest" />
<Message Text="Finished Copying artifacts to '$(ArtifactDestination)'" Importance="high"/>
</Target>
<Target Name="CopyArtifacts" AfterTargets="Build" Condition="'$(BeatSaberRelease)' != 'True' AND '$(DisableCopyArtifacts)' != 'True'">
<Message Text="Copying $(TargetFramework) artifacts to '$(ArtifactDestination)'" Importance="high"/>
<Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFiles="$(ArtifactDestination)\$(AssemblyName).dll" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).xml" DestinationFiles="$(ArtifactDestination)\$(AssemblyName).xml" />
<Message Text="Finished Copying artifacts to '$(ArtifactDestination)'" Importance="high"/>
</Target>
<!--Build target for Continuous Integration builds. Set up for GitHub Actions.-->
<Target Name="BuildForCI" AfterTargets="CopyArtifacts;CopyBeatSaberArtifacts" DependsOnTargets="SetFullReleaseInfo"
Condition="'$(ContinuousIntegrationBuild)' == 'True' AND '$(DisableCopyArtifacts)' != 'True'">
<Message Text="Building for CI" Importance="high" />
<Message Text="::set-output name=filename::$(ReleaseName)" Importance="high" />
<Message Text="::set-output name=assemblyname::$(AssemblyName)" Importance="high" />
<Message Text="::set-output name=projectdir::$(ProjectDir)" Importance="high" />
<Message Text="::set-output name=artifactpath::$(ProjectDir)$(ArtifactDestination)" Importance="high" />
<!--<Message Condition="'$(BeatSaberRelease)' == 'True'"
Text="::set-output name=release-title::$(AssemblyName).BeatSaber v$(Version)" Importance="high" />-->
<!--Condition="'$(BeatSaberRelease)' != 'True'"-->
<Message Text="::set-output name=release-title::$(AssemblyName) v$(Version)" Importance="high" />
</Target>
<!--Creates a BeatMods compliant zip file with the release.-->
<Target Name="ZipRelease" AfterTargets="CopyBeatSaberArtifacts;CopyArtifacts"
DependsOnTargets="CopyArtifacts;CopyBeatSaberArtifacts;SetFullReleaseInfo"
Condition="'$(DisableZipRelease)' != 'True' AND '$(DisableCopyArtifacts)' != 'True' AND '$(BSMTTaskAssembly)' != ''">
<!--Set 'ReleaseName' if it failed before.-->
<PropertyGroup Condition="'$(ReleaseName)' == '' AND '$(BeatSaberRelease)' == 'True'">
<ReleaseName>$(AssemblyName)-$(Version)-bs$(GameVersion)-$(CommitHash)</ReleaseName>
</PropertyGroup>
<PropertyGroup Condition="'$(ReleaseName)' == '' AND '$(BeatSaberRelease)' != 'True'">
<ReleaseName>$(AssemblyName)-$(Version)-$(CommitHash)</ReleaseName>
</PropertyGroup>
<PropertyGroup>
<DestinationDirectory>$(OutDir)zip\</DestinationDirectory>
</PropertyGroup>
<ItemGroup>
<OldZips Include="$(DestinationDirectory)$(AssemblyName)*.zip"/>
</ItemGroup>
<Message Text="PluginVersion: $(Version), AssemblyVersion: $(AssemblyVersion), GameVersion: $(GameVersion)" Importance="high" />
<Delete Files="@(OldZips)" TreatErrorsAsWarnings="true" ContinueOnError="true" />
<ZipDir SourceDirectory="$(ArtifactDestination)" DestinationFile="$(DestinationDirectory)$(ReleaseName).zip" />
<Message Condition="'$(ContinuousIntegrationBuild)' == 'True'"
Text="::set-output name=zippath::$(ProjectDir)$(DestinationDirectory)$(ReleaseName).zip" Importance="high" />
</Target>
<!--Copies the assembly and pdb to the Beat Saber folder.-->
<Target Name="CopyToPlugins" AfterTargets="Build" Condition="'$(BeatSaberRelease)' == 'True' AND '$(DisableCopyToPlugins)' != 'True'">
<PropertyGroup>
<PluginDir>$(BeatSaberDir)\Plugins</PluginDir>
<LibsDir>$(BeatSaberDir)\Libs</LibsDir>
<CanCopyToPlugins>True</CanCopyToPlugins>
<CopyToPluginsError Condition="!Exists('$(PluginDir)')">Unable to copy assembly to game folder, did you set 'BeatSaberDir' correctly in your 'csproj.user' file? Plugins folder doesn't exist: '$(PluginDir)'.</CopyToPluginsError>
<CopyToPluginsError Condition="!Exists('$(LibsDir)')">Unable to copy assembly to game folder, did you set 'BeatSaberDir' correctly in your 'csproj.user' file? Libs folder doesn't exist: '$(LibsDir)'.</CopyToPluginsError>
<!--Error if 'BeatSaberDir' does not have 'Beat Saber.exe'-->
<CopyToPluginsError Condition="!Exists('$(BeatSaberDir)\Beat Saber.exe')">Unable to copy to Plugins folder, '$(BeatSaberDir)' does not appear to be a Beat Saber game install.</CopyToPluginsError>
<!--Error if 'BeatSaberDir' is the same as 'LocalRefsDir'-->
<CopyToPluginsError Condition="'$(BeatSaberDir)' == '$(LocalRefsDir)' OR '$(BeatSaberDir)' == ''">Unable to copy to Plugins folder, 'BeatSaberDir' has not been set in your 'csproj.user' file.</CopyToPluginsError>
<CanCopyToPlugins Condition="'$(CopyToPluginsError)' != ''">False</CanCopyToPlugins>
</PropertyGroup>
<IsProcessRunning ProcessName="Beat Saber">
<Output TaskParameter="IsRunning" PropertyName="IsRunning" />
</IsProcessRunning>
<PropertyGroup Condition="'$(IsRunning)' == 'True'">
<PluginDir>$(BeatSaberDir)\IPA\Pending\Plugins</PluginDir>
<LibsDir>$(BeatSaberDir)\IPA\Pending\Libs</LibsDir>
</PropertyGroup>
<PropertyGroup Condition="'$(IsRunning)' == 'False'">
<PluginDir>$(BeatSaberDir)\Plugins</PluginDir>
<LibsDir>$(BeatSaberDir)\Libs</LibsDir>
</PropertyGroup>
<Warning Text="$(CopyToPluginsError)" Condition="'$(CopyToPluginsError)' != ''" />
<Message Text="Copying $(OutputPath)$(AssemblyName).dll to $(LibsDir)" Importance="high" Condition="$(CanCopyToPlugins)" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFiles="$(LibsDir)\$(AssemblyName).dll" Condition="$(CanCopyToPlugins)" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).pdb" DestinationFiles="$(LibsDir)\$(AssemblyName).pdb" Condition="$(CanCopyToPlugins)" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).xml" DestinationFiles="$(LibsDir)\$(AssemblyName).xml" Condition="$(CanCopyToPlugins)" />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).manifest" DestinationFiles="$(PluginDir)\$(AssemblyName).manifest" Condition="$(CanCopyToPlugins)" />
</Target>
</Project>