mirror of
https://github.com/koloml/vs-manual-cartography.git
synced 2026-06-23 18:22:21 +00:00
Initial commit from Vintage Story mod template
This commit adds dummy compass item wich will just send the angle into the chat when you click RMB on it.
This commit is contained in:
20
CakeBuild/CakeBuild.csproj
Normal file
20
CakeBuild/CakeBuild.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cake.Frosting" Version="6.1.0"/>
|
||||
<PackageReference Include="Cake.Json" Version="7.0.1"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="VintagestoryAPI">
|
||||
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
119
CakeBuild/Program.cs
Normal file
119
CakeBuild/Program.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
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;
|
||||
|
||||
namespace CakeBuild;
|
||||
|
||||
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 = "ManualCartography";
|
||||
public string BuildConfiguration { get; }
|
||||
public string Version { get; }
|
||||
public string Name { get; }
|
||||
public bool SkipJsonValidation { get; }
|
||||
|
||||
public BuildContext(ICakeContext context)
|
||||
: base(context)
|
||||
{
|
||||
BuildConfiguration = context.Argument("configuration", "Release");
|
||||
SkipJsonValidation = context.Argument("skipJsonValidation", false);
|
||||
var modInfo = context.DeserializeJsonFromFile<ModInfo>($"../{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}");
|
||||
if (context.DirectoryExists($"../{BuildContext.ProjectName}/assets"))
|
||||
{
|
||||
context.CopyDirectory($"../{BuildContext.ProjectName}/assets", $"../Releases/{context.Name}/assets");
|
||||
}
|
||||
context.CopyFile($"../{BuildContext.ProjectName}/modinfo.json", $"../Releases/{context.Name}/modinfo.json");
|
||||
if (context.FileExists($"../{BuildContext.ProjectName}/modicon.png"))
|
||||
{
|
||||
context.CopyFile($"../{BuildContext.ProjectName}/modicon.png", $"../Releases/{context.Name}/modicon.png");
|
||||
}
|
||||
context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_{context.Version}.zip");
|
||||
}
|
||||
}
|
||||
|
||||
[TaskName("Default")]
|
||||
[IsDependentOn(typeof(PackageTask))]
|
||||
public class DefaultTask : FrostingTask
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user