Skip to content

Commit 8e790c8

Browse files
committed
迁移到 Cake 构建系统
1 parent b89aa17 commit 8e790c8

File tree

8 files changed

+122
-2
lines changed

8 files changed

+122
-2
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ jobs:
3131
run: cp AquaMai-Build-Assets/WorldLinkLibs/* mod/Libs/
3232

3333
- name: Build .NET Mod
34-
run: cd mod && dotnet build -c Release
34+
run: |
35+
cd mod
36+
dotnet tool restore
37+
dotnet cake
3538
3639
- name: Rename Artifacts
3740
run: |

mod/.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "5.0.0",
7+
"commands": [
8+
"dotnet-cake"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

mod/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,6 @@ Assembly-CSharp-firstpass.dll
377377
AMDaemon.NET.dll
378378
packages
379379
.DS_Store
380-
._*
380+
._*
381+
*.g.cs
382+
tools

mod/BuildInfo.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace WorldLink;
2+
3+
public static partial class BuildInfo
4+
{
5+
public const string Name = "WorldLink";
6+
public const string Author = "Azalea & Clansty & Japerz";
7+
}
8+

mod/WorldLink.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@
255255
</PropertyGroup>
256256

257257
<ItemGroup>
258+
<Compile Include="BuildInfo.cs" />
258259
<Compile Include="Compat.cs" />
259260
<Compile Include="Core.cs" />
260261
<Compile Include="WorldLink\FutariClient.cs" />
@@ -263,4 +264,8 @@
263264
<Compile Include="WorldLink\FutariSocket.cs" />
264265
<Compile Include="WorldLink\FutariTypes.cs" />
265266
</ItemGroup>
267+
268+
<ItemGroup>
269+
<Content Include=".config\dotnet-tools.json" />
270+
</ItemGroup>
266271
</Project>

mod/build-install.cmd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
chcp 65001
2+
dotnet build -c Debug
3+
4+
copy /y ".\bin\Debug\net472\WorldLink.dll" "m:\Package\Mods"
5+
rem call "e:\Maimai HDD\1.bat"
6+
7+
pushd m:\
8+
9+
pushd AMDaemon
10+
start /min inject -d -k mai2hook.dll amdaemon.exe -f -c config_common.json config_server.json config_client.json
11+
popd
12+
13+
pushd Package
14+
sinmai.exe
15+
pushd Package
16+
17+
taskkill /f /im amdaemon.exe
18+
19+
rem nya~

mod/build.cake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#addin nuget:?package=Cake.Git&version=5.0.1
2+
#addin nuget:?package=Cake.FileHelpers&version=7.0.0
3+
4+
var target = Argument("target", "Build");
5+
var configuration = Argument("configuration", "Release");
6+
7+
Task("Restore")
8+
.Does(() =>
9+
{
10+
// 运行 dotnet restore
11+
DotNetRestore("./WorldLink.sln");
12+
});
13+
14+
Task("PreBuild")
15+
.Does(() =>
16+
{
17+
var gitDescribe = GitDescribe("..", GitDescribeStrategy.Tags).Substring(1); // 获取 git describe 的输出
18+
var buildDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
19+
20+
var shortVers = gitDescribe.Split('-');
21+
string shortVer;
22+
if (shortVers.Length > 1)
23+
{
24+
shortVer = $"{shortVers[0]}.{shortVers[1]}";
25+
}
26+
else
27+
{
28+
shortVer = shortVers[0];
29+
}
30+
31+
var versionContent = $@"
32+
// Auto-generated file. Do not modify manually.
33+
namespace WorldLink;
34+
35+
public static partial class BuildInfo
36+
{{
37+
public const string Version = ""{shortVer}"";
38+
public const string GitVersion = ""{gitDescribe}"";
39+
public const string BuildDate = ""{buildDate}"";
40+
}}
41+
";
42+
FileWriteText("./BuildInfo.g.cs", versionContent);
43+
});
44+
45+
Task("Build")
46+
.IsDependentOn("PreBuild")
47+
.IsDependentOn("Restore")
48+
.Does(() =>
49+
{
50+
// 使用 dotnet build 进行构建
51+
DotNetBuild("./WorldLink.sln", new DotNetBuildSettings
52+
{
53+
Configuration = configuration
54+
});
55+
});
56+
57+
RunTarget(target);

mod/build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
Set-Location -LiteralPath $PSScriptRoot
4+
5+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
6+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
7+
$env:DOTNET_NOLOGO = '1'
8+
9+
dotnet tool restore
10+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
11+
12+
dotnet cake @args
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

0 commit comments

Comments
 (0)