Skip to content

Commit

Permalink
chore: migrate assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyupe committed Jan 31, 2025
1 parent ff44b4b commit af6b973
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 81 deletions.
7 changes: 1 addition & 6 deletions Cafe.Matcha.Packer/Cafe.Matcha.Packer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<OutputPath>..\bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<None Update="assets\manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
45 changes: 9 additions & 36 deletions Cafe.Matcha.Packer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,10 @@ namespace Cafe.Matcha.Packer

public class Program
{
private static void GenerateAssembly()
{
string version = DateTime.UtcNow.ToString("yy.M.d.Hmm");

var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\Cafe.Matcha\AssemblyCopyright.cs");
var template = @"// Copyright (c) FFCafe. All rights reserved.
// Licensed under the AGPL-3.0 license. See LICENSE file in the project root for full license information.
using System.Reflection;
[assembly: AssemblyTitle(""Cafe.Matcha"")]
[assembly: AssemblyDescription(""Cafe.Matcha"")]
[assembly: AssemblyCompany(""FFCafe"")]
[assembly: AssemblyVersion(""{0}"")]
[assembly: AssemblyCopyright(""Copyright © FFCafe {1}"")]
namespace Cafe.Matcha
{
public partial class Data
{
public const string Version = ""{0}"";
}
private const string Manifest = @"{
""entryPoint"": ""Plugins/Cafe.Matcha/Cafe.Matcha.dll""
}
";
var content = template.Replace("{0}", version).Replace("{1}", DateTime.Now.Year.ToString());
Console.WriteLine(content);
File.WriteAllText(path, content);
}

private static void Bundle(string env)
{
var root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, env);
Expand All @@ -51,7 +26,12 @@ private static void Bundle(string env)
{
using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true))
{
archive.CreateEntryFromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @".\assets\manifest.json"), "manifest.json");
var manifestEntry = archive.CreateEntry("manifest.json");
using (var entryStream = manifestEntry.Open())
using (var streamWriter = new StreamWriter(entryStream))
{
streamWriter.Write(Manifest);
}

foreach (var dll in Directory.GetFiles(root, "*.dll"))
{
Expand All @@ -75,14 +55,7 @@ private static void Bundle(string env)
private static void Main(string[] args)
{
string env = args.Length >= 1 ? args[0] : "Release";
if (env == "Assembly")
{
GenerateAssembly();
}
else
{
Bundle(env);
}
Bundle(env);
}
}
}
21 changes: 0 additions & 21 deletions Cafe.Matcha.Packer/Properties/AssemblyInfo.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Cafe.Matcha.Packer/assets/manifest.json

This file was deleted.

1 change: 0 additions & 1 deletion Cafe.Matcha/.gitignore

This file was deleted.

19 changes: 7 additions & 12 deletions Cafe.Matcha/Cafe.Matcha.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>8.0</LangVersion>
<OutputType>Library</OutputType>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<StartupObject></StartupObject>
<Obfuscate>true</Obfuscate>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup>
<Company>FFCafe</Company>
<Copyright>Copyright © FFCafe $([System.DateTime]::UtcNow.Year)</Copyright>
<Version>$([System.DateTime]::UtcNow.ToString("yy.M.d.Hmm"))</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\bin\Debug\</OutputPath>
</PropertyGroup>
Expand Down Expand Up @@ -99,7 +103,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Confuser.MSBuild">
<Version>1.4.1</Version>
<Version>1.6.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -126,19 +130,10 @@
<PackageReference Include="RecursiveChangeNotifier">
<Version>0.4.0</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Reactive">
<Version>6.0.1</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup />
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="$(OutDir)..\Cafe.Matcha.Packer Assembly&#xD;&#xA;cd $(ProjectDir)Constant\&#xD;&#xA;&#xD;&#xA;if not exist Secret.Local.cs (&#xD;&#xA; type nul &gt; Secret.Local.cs&#xD;&#xA;)" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del $(OutDir) /F&#xD;&#xA;xcopy &quot;$(OutDir)confused\*.*&quot; &quot;$(OutDir)&quot; /E /Y /C&#xD;&#xA;$(OutDir)..\Cafe.Matcha.Packer $(ConfigurationName)" />
</Target>
Expand Down
5 changes: 4 additions & 1 deletion Cafe.Matcha/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ namespace Cafe.Matcha
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows;
using Cafe.Matcha.Utils;
using Newtonsoft.Json;

public partial class Data : StaticBindingTarget<Data>
public class Data : StaticBindingTarget<Data>
{
#if GLOBAL
public const string Title = "Matcha";
#else
public const string Title = "抹茶 Matcha";
#endif
public static string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

public Dictionary<int, Models.FateData> Fates { get; set; }
public Dictionary<int, Models.DynamicEventData> DynamicEvents;
public Dictionary<int, Models.InstanceData> Instances;
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<!-- StyleCop Analyzers configuration -->
<!-- StyleCop Analyzers configuration -->
<PropertyGroup>
<CodeAnalysisRuleSet>$(SolutionDir)StyleCop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down

0 comments on commit af6b973

Please sign in to comment.