Fix mainBin when not specified

This commit is contained in:
CreepyCrafter24 2020-03-11 19:41:51 +01:00
parent 43a3f99d1b
commit 068d5de355

View File

@ -57,7 +57,6 @@ namespace UpTool_build_tool
.Where(s => new[] { ".xml", ".pdb" }.Contains(Path.GetExtension(s)))
.ToList().ForEach(File.Delete);
Console.WriteLine("Creating batch scripts...");
string programName = Path.GetFileNameWithoutExtension(mainBin);
if (noShortcuts)
{
File.WriteAllText(Path.Combine(tempPath, "Install.bat"), "@echo off\r\necho INSTALL\r\ntimeout /t 1");
@ -65,6 +64,8 @@ namespace UpTool_build_tool
}
else
{
mainBin = string.IsNullOrWhiteSpace(mainBin) ? Directory.GetFiles(binDir, "*.exe")[0] : mainBin;
string programName = Path.GetFileNameWithoutExtension(mainBin);
File.WriteAllText(Path.Combine(tempPath, "Install.bat"),
$"@echo off\r\necho INSTALL\r\npowershell \"$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\{programName}.lnk');$s.TargetPath='%cd%\\{programName}.exe';$s.Save()\"\r\ntimeout /t 1");
File.WriteAllText(Path.Combine(tempPath, "Remove.bat"),