Skip to content

Commit

Permalink
change name
Browse files Browse the repository at this point in the history
  • Loading branch information
yibei333 committed Oct 8, 2024
1 parent 019ab40 commit a869510
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion assets/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3.3-alpha
1.0.3.4-alpha
2 changes: 1 addition & 1 deletion src/SingleExe.Tool/SingleExe.Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.0.3.3-alpha</Version>
<Version>1.0.3.4-alpha</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageReadmeFile>Nuget.md</PackageReadmeFile>
<AssemblyName>single-exe</AssemblyName>
Expand Down
76 changes: 39 additions & 37 deletions src/SingleExe/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,51 @@ public MainWindow()
StartAsync();
}

async void StartAsync()
void StartAsync()
{
await Task.Yield();
try
Task.Factory.StartNew(() =>
{
var tempFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"{App.Name}\\{App.Version}");
var integrityFile = Path.Combine(tempFolder, "integrity.txt");
var exePath = Path.Combine(tempFolder, App.EntryPoint);
if (!File.Exists(integrityFile) || !File.Exists(exePath))
try
{
if (Directory.Exists(tempFolder)) Directory.Delete(tempFolder, true);
if (!Directory.Exists(tempFolder)) Directory.CreateDirectory(tempFolder);
var zipFile = Path.Combine(tempFolder, "Source.zip");
if (File.Exists(zipFile)) File.Delete(zipFile);
var tempFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"{App.Name}\\{App.Version}");
var versionFile = Path.Combine(tempFolder, "version.txt");
var exePath = Path.Combine(tempFolder, App.EntryPoint);
if (!File.Exists(versionFile) || !File.Exists(exePath))
{
if (Directory.Exists(tempFolder)) Directory.Delete(tempFolder, true);
if (!Directory.Exists(tempFolder)) Directory.CreateDirectory(tempFolder);
var zipFile = Path.Combine(tempFolder, "Source.zip");
if (File.Exists(zipFile)) File.Delete(zipFile);
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"SingleExe.Source.zip");
var zipStream = new FileStream(zipFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
stream.CopyTo(zipStream);
zipStream.Flush();
zipStream.Dispose();
stream.Dispose();
ZipFile.ExtractToDirectory(zipFile, tempFolder);
File.Delete(zipFile);
}
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"SingleExe.Source.zip");
var zipStream = new FileStream(zipFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
stream.CopyTo(zipStream);
zipStream.Flush();
zipStream.Dispose();
stream.Dispose();
ZipFile.ExtractToDirectory(zipFile, tempFolder);
File.Delete(zipFile);
}
if (!File.Exists(exePath)) throw new Exception($"file not found:{exePath}");
var process = new Process
{
StartInfo = new ProcessStartInfo(exePath, string.Join(" ", Environment.GetCommandLineArgs()))
if (!File.Exists(exePath)) throw new Exception($"file not found:{exePath}");
var process = new Process
{
WorkingDirectory = new FileInfo(exePath).DirectoryName,
CreateNoWindow = true
}
};
process.Start();
StartInfo = new ProcessStartInfo(exePath, string.Join(" ", Environment.GetCommandLineArgs()))
{
WorkingDirectory = new FileInfo(exePath).DirectoryName,
CreateNoWindow = true
}
};
process.Start();
if (!File.Exists(integrityFile)) File.Create(integrityFile).Close();
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Application.Current.Shutdown(1);
}
if (!File.Exists(versionFile)) File.WriteAllText(versionFile, App.Version);
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Application.Current.Shutdown(1);
}
});
}
}

0 comments on commit a869510

Please sign in to comment.