Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Windows平台自动更新完成
Browse files Browse the repository at this point in the history
  • Loading branch information
JWJUN233233 committed Jan 19, 2023
1 parent 2b96f7a commit 878f90d
Show file tree
Hide file tree
Showing 241 changed files with 3,152 additions and 504 deletions.
Binary file modified .vs/ProjectEvaluation/wonderlabx.metadata.v2
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/wonderlabx.projects.v2
Binary file not shown.
Binary file modified .vs/WonderLabX/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/WonderLabX/v17/.futdcache.v1
Binary file not shown.
Binary file modified .vs/WonderLabX/v17/.suo
Binary file not shown.
98 changes: 98 additions & 0 deletions Updata/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System.Diagnostics;
using System.IO.Compression;

namespace Updataer
{
public class Updataer
{
/// <summary>
/// 解压Zip文件到指定目录
/// </summary>
/// <param name="zipPath">zip地址</param>
/// <param name="folderPath">文件夹地址</param>
public static void DecompressZip(string zipPath, string folderPath)
{
DirectoryInfo directoryInfo = new(folderPath);

if (!directoryInfo.Exists)
{
directoryInfo.Create();
}

try
{
//Declare a temporary path to unzip your files
string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "tempUnzip");
string extractPath = Directory.GetCurrentDirectory();
ZipFile.ExtractToDirectory(zipPath, tempPath);

//build an array of the unzipped files
string[] files = Directory.GetFiles(tempPath);

foreach (string file in files)
{
FileInfo f = new FileInfo(file);
//Check if the file exists already, if so delete it and then move the new file to the extract folder
if (File.Exists(Path.Combine(extractPath, f.Name)))
{
File.Delete(Path.Combine(extractPath, f.Name));
File.Move(f.FullName, Path.Combine(extractPath, f.Name));
}
else
{
File.Move(f.FullName, Path.Combine(extractPath, f.Name));
}
}
//Delete the temporary directory.
Directory.Delete(tempPath);
}
catch (Exception)
{

}
}
public static void Main(string[] args)
{
Thread.Sleep(1000);
if(args.Length == 0)
{
if(File.Exists(Path.Combine(Path.GetTempPath(), "WonderLab-updata.exe")))
{
File.Delete(Path.Combine(Path.GetTempPath(), "WonderLab-updata.exe"));
}
File.Copy("Updata.exe", Path.Combine(Path.GetTempPath(), "WonderLab-updata.exe"));
if (File.Exists(Path.Combine(Path.GetTempPath(), "Updata.dll")))
{
File.Delete(Path.Combine(Path.GetTempPath(), "Updata.dll"));
}
File.Copy("Updata.dll", Path.Combine(Path.GetTempPath(), "Updata.dll"));
if (File.Exists(Path.Combine(Path.GetTempPath(), "Updata.deps.json")))
{
File.Delete(Path.Combine(Path.GetTempPath(), "Updata.deps.json"));
}
File.Copy("Updata.deps.json", Path.Combine(Path.GetTempPath(), "Updata.deps.json"));
if (File.Exists(Path.Combine(Path.GetTempPath(), "Updata.runtimeconfig.json")))
{
File.Delete(Path.Combine(Path.GetTempPath(), "Updata.runtimeconfig.json"));
}
File.Copy("Updata.runtimeconfig.json", Path.Combine(Path.GetTempPath(), "Updata.runtimeconfig.json"));
Process pro = new Process();
pro.StartInfo.FileName = Path.Combine(Path.GetTempPath(), "WonderLab-updata.exe");
pro.StartInfo.Arguments = "-updata " + Path.Combine("updata-cache", "updata.zip") + " " + Path.Combine(Environment.CurrentDirectory) + " " + Path.Combine(System.Environment.CurrentDirectory,"WonderLab.exe");
File.Delete(Path.Combine("updata-cache", "UpdataNextTime"));
pro.Start();
return;
}
else if(args.Length == 4)
{
if(args[0] == "-updata")
{
DecompressZip(args[1], args[2]);
Process pro = new Process();
pro.StartInfo.FileName = args[3];
pro.Start();
}
}
}
}
}
10 changes: 10 additions & 0 deletions Updata/Updata.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions Updata/bin/Debug/net6.0/Plugins/Plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
23 changes: 23 additions & 0 deletions Updata/bin/Debug/net6.0/Updata.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"Updata/1.0.0": {
"runtime": {
"Updata.dll": {}
}
}
}
},
"libraries": {
"Updata/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file added Updata/bin/Debug/net6.0/Updata.dll
Binary file not shown.
Binary file added Updata/bin/Debug/net6.0/Updata.exe
Binary file not shown.
Binary file added Updata/bin/Debug/net6.0/Updata.pdb
Binary file not shown.
9 changes: 9 additions & 0 deletions Updata/bin/Debug/net6.0/Updata.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
}
}
}
Loading

0 comments on commit 878f90d

Please sign in to comment.