Skip to content

Commit

Permalink
Implement SwitchDevelopmentChannel in NanaZip.RefreshPackageVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Aug 14, 2024
1 parent ca0fbdb commit 351c6a5
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions NanaZip.RefreshPackageVersion/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mile.Project.Helpers;
using System.Text;
using System.Xml;

namespace NanaZip.RefreshPackageVersion
Expand Down Expand Up @@ -49,10 +50,88 @@ static void RefreshAppxManifestVersion()
}
}

static void ReplaceFileContentViaStringList(
string FilePath,
List<string> FromList,
List<string> ToList)
{
if (FromList.Count != ToList.Count)
{
throw new ArgumentOutOfRangeException();
}

string Content = File.ReadAllText(FilePath, Encoding.UTF8);

for (int Index = 0; Index < FromList.Count; ++Index)
{
Content = Content.Replace(FromList[Index], ToList[Index]);
}

if (Path.GetExtension(FilePath) == ".rc")
{
File.WriteAllText(FilePath, Content, Encoding.Unicode);
}
else
{
FileUtilities.SaveTextToFileAsUtf8Bom(FilePath, Content);
}
}

static bool SwitchToPreview = true;

static List<string> ReleaseStringList = new List<string>
{
"DisplayName=\"NanaZip\"",
"Name=\"40174MouriNaruto.NanaZip\"",
"<DisplayName>NanaZip</DisplayName>",
"CAE3F1D4-7765-4D98-A060-52CD14D56EAB",
"return ::SHStrDupW(L\"NanaZip\", ppszName);",
"<Content Include=\"..\\Assets\\PackageAssets\\**\\*\">",
"Assets/NanaZip.ico",
"Assets/NanaZipSfx.ico",
};

static List<string> PreviewStringList = new List<string>
{
"DisplayName=\"NanaZip Preview\"",
"Name=\"40174MouriNaruto.NanaZipPreview\"",
"<DisplayName>NanaZip Preview</DisplayName>",
"469D94E9-6AF4-4395-B396-99B1308F8CE5",
"return ::SHStrDupW(L\"NanaZip Preview\", ppszName);",
"<Content Include=\"..\\Assets\\PreviewPackageAssets\\**\\*\">",
"Assets/NanaZipPreview.ico",
"Assets/NanaZipPreviewSfx.ico",
};

static List<string> FileList = new List<string>
{
@"{0}\NanaZipPackage\Package.appxmanifest",
@"{0}\NanaZip.UI.Modern\NanaZip.ShellExtension.cpp",
@"{0}\NanaZipPackage\NanaZipPackage.wapproj",
@"{0}\NanaZip.UI.Modern\SevenZip\CPP\7zip\UI\FileManager\resource.rc",
@"{0}\NanaZip.UI.Modern\SevenZip\CPP\7zip\UI\GUI\resource.rc",
@"{0}\NanaZip.Core\SevenZip\CPP\7zip\Bundles\SFXCon\resource.rc",
@"{0}\NanaZip.Core\SevenZip\CPP\7zip\Bundles\SFXSetup\resource.rc",
@"{0}\NanaZip.Core\SevenZip\CPP\7zip\Bundles\SFXWin\resource.rc",
};

static void SwitchDevelopmentChannel()
{
foreach (var FilePath in FileList)
{
ReplaceFileContentViaStringList(
string.Format(FilePath, RepositoryRoot),
SwitchToPreview ? ReleaseStringList : PreviewStringList,
SwitchToPreview ? PreviewStringList : ReleaseStringList);
}
}

static void Main(string[] args)
{
RefreshAppxManifestVersion();

SwitchDevelopmentChannel();

Console.WriteLine(
"NanaZip.RefreshPackageVersion task has been completed.");
Console.ReadKey();
Expand Down

0 comments on commit 351c6a5

Please sign in to comment.