Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions code_mods/WorldGen_AlpineStory/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-dotnettools.csharp"
]
}
61 changes: 61 additions & 0 deletions code_mods/WorldGen_AlpineStory/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Client (Debug)",
"type": "coreclr",
"request": "launch",
"program": "${env:VINTAGE_STORY}/Vintagestory.exe",
"linux": {
"program": "${env:VINTAGE_STORY}/Vintagestory"
},
"osx": {
"program": "${env:VINTAGE_STORY}/Vintagestory"
},
"preLaunchTask": "build",
"args": [
// "--playStyle" , "preset-surviveandbuild",
// "--openWorld" , "modding test world",
"--tracelog",
"--addModPath",
"${workspaceFolder}/AlpineStory/bin/Debug/Mods"
],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Launch Server",
"type": "coreclr",
"request": "launch",
"program": "${env:VINTAGE_STORY}/VintagestoryServer.exe",
"linux": {
"program": "${env:VINTAGE_STORY}/VintagestoryServer"
},
"osx": {
"program": "${env:VINTAGE_STORY}/VintagestoryServer"
},
"preLaunchTask": "build",
"args": [
"--tracelog",
"--addModPath",
"${workspaceFolder}/AlpineStory/bin/Debug/Mods"
],
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "CakeBuild",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build (Cake)",
"program": "${workspaceFolder}/CakeBuild/bin/Debug/net7.0/CakeBuild.dll",
"args": [],
"cwd": "${workspaceFolder}/CakeBuild",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
40 changes: 40 additions & 0 deletions code_mods/WorldGen_AlpineStory/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-c",
"Debug",
"${workspaceFolder}/AlpineStory/AlpineStory.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "package",
"command": "dotnet",
"type": "process",
"args": [
"run",
"--project",
"${workspaceFolder}/CakeBuild/CakeBuild.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "build (Cake)",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-c",
"Debug",
"${workspaceFolder}/CakeBuild/CakeBuild.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
19 changes: 19 additions & 0 deletions code_mods/WorldGen_AlpineStory/CakeBuild/CakeBuild.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="3.0.0" />
<PackageReference Include="Cake.Json" Version="7.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<Reference Include="VintagestoryAPI">
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
110 changes: 110 additions & 0 deletions code_mods/WorldGen_AlpineStory/CakeBuild/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using System;
using System.IO;
using Cake.Common;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Clean;
using Cake.Common.Tools.DotNet.Publish;
using Cake.Core;
using Cake.Frosting;
using Cake.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Vintagestory.API.Common;

public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.UseContext<BuildContext>()
.Run(args);
}
}

public class BuildContext : FrostingContext
{
public const string ProjectName = "AlpineStory";
public string BuildConfiguration { get; set; }
public string Version { get; }
public string Name { get; }
public bool SkipJsonValidation { get; set; }

public BuildContext(ICakeContext context)
: base(context)
{
BuildConfiguration = context.Argument("configuration", "Release");
SkipJsonValidation = context.Argument("skipJsonValidation", false);
var modInfo = context.DeserializeJsonFromFile<ModInfo>($"../{BuildContext.ProjectName}/modinfo.json");
Version = modInfo.Version;
Name = modInfo.ModID;
}
}

[TaskName("ValidateJson")]
public sealed class ValidateJsonTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
if (context.SkipJsonValidation)
{
return;
}
var jsonFiles = context.GetFiles($"../{BuildContext.ProjectName}/assets/**/*.json");
foreach (var file in jsonFiles)
{
try
{
var json = File.ReadAllText(file.FullPath);
JToken.Parse(json);
}
catch (JsonException ex)
{
throw new Exception($"Validation failed for JSON file: {file.FullPath}{Environment.NewLine}{ex.Message}", ex);
}
}
}
}

[TaskName("Build")]
[IsDependentOn(typeof(ValidateJsonTask))]
public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.DotNetClean($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj",
new DotNetCleanSettings
{
Configuration = context.BuildConfiguration
});


context.DotNetPublish($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj",
new DotNetPublishSettings
{
Configuration = context.BuildConfiguration
});
}
}

[TaskName("Package")]
[IsDependentOn(typeof(BuildTask))]
public sealed class PackageTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.EnsureDirectoryExists("../Releases");
context.CleanDirectory("../Releases");
context.EnsureDirectoryExists($"../Releases/{context.Name}");
context.CopyFiles($"../{BuildContext.ProjectName}/bin/{context.BuildConfiguration}/Mods/mod/publish/*", $"../Releases/{context.Name}");
context.CopyDirectory($"../{BuildContext.ProjectName}/assets", $"../Releases/{context.Name}/assets");
context.CopyFile($"../{BuildContext.ProjectName}/modinfo.json", $"../Releases/{context.Name}/modinfo.json");
context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_{context.Version}.zip");
}
}

[TaskName("Default")]
[IsDependentOn(typeof(PackageTask))]
public class DefaultTask : FrostingTask
{
}
Loading