Skip to content

Commit

Permalink
Fixed updater not working
Browse files Browse the repository at this point in the history
- Should fix updater not working (Requiring .NET 6, but running outdated installer and resulting in a loop).
- Removed icon changer, and title set for account switcher server that was causing some crashes.
  • Loading branch information
TCNOco committed Dec 8, 2021
1 parent 8dc480f commit be87582
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 212 deletions.
27 changes: 15 additions & 12 deletions Installer/Installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ bool args_contain(const char* needle, int argc, char* argv[])
return false;
}

void launch_dll(char* arg)
void launch_tcno_program(const char* arg)
{
std::string p = '"' + getOperatingPath();
if (p.back() != '\\') p += '\\';
const std::string program = arg;
const std::string program(arg);
std::string operating_path = getOperatingPath();
const std::string exe_name = program + "_main.exe";

// Add updater\\ if updater.exe
if (program.find_last_of("updater") != std::string::npos || program.find_last_of("Updater") != std::string::npos)
p += "updater\\";
std::string full_path = operating_path;
if (full_path.back() != '\\') full_path += '\\';
full_path += exe_name;

p = p + arg + ".dll\"";
std::cout << "Running: " << exe_name << std::endl;

std::vector<char> buffer_temp;

std::string dotnet = dotnet_path();
exec_program(std::wstring(dotnet.begin(), dotnet.end()), L"dotnet.exe", std::wstring(p.begin(), p.end()), false);
std::cout << "FULL PATH: " << full_path << std::endl;

exec_program(std::wstring(operating_path.begin(), operating_path.end()),
std::wstring(exe_name.begin(), exe_name.end()), L"");
}

int main(int argc, char* argv[])
Expand Down Expand Up @@ -66,11 +69,11 @@ int main(int argc, char* argv[])
min_vc_met = true; // Skip over this. Not needed unless CEF enabled --> Checked elsewhere.
verify_net();
if (argc > 2)
launch_dll(argv[argc - 1]);
launch_tcno_program(argv[argc - 1]);
exit(1);
}

launch_dll(argv[argc - 1]);
launch_tcno_program(argv[argc - 1]);
}

cout << "Currently installed runtimes:" << endl;
Expand Down
2 changes: 1 addition & 1 deletion Installer/runtime_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool compare_versions(std::string v1, std::string v2, const std::string& delimit
return true;
} catch (std::exception &err)
{
std::cout << "Version conversion failed!" << std::endl;
std::cout << "Version conversion failed!" << std::endl << "Details:" << std::endl << err.what() << std::endl;
}

return true;
Expand Down
7 changes: 4 additions & 3 deletions Installer/tcno.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void insert_empty_line()

double round_off(const double n) {
double d = n * 100.0;
const int i = d + 0.5;
d = static_cast<float>(i) / 100.0;
const int i = static_cast<int>((double)0.5 + d);
d = static_cast<double>(i) / 100.0;
return d;
}

Expand Down Expand Up @@ -116,7 +116,8 @@ int progress_bar(

bool download_file(const char* url, const char* dest) {
if (CURL* curl = curl_easy_init(); curl) {
FILE* fp = fopen(dest, "wb");
FILE* fp;
fopen_s(&fp, dest, "wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
Expand Down
157 changes: 16 additions & 141 deletions TcNo-Acc-Switcher-Client/PostBuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,6 @@ REM Get current directory:
echo Current directory: %cd%
set origDir=%cd%

REM Move updater files in Debug folder (for Visual Studio):
IF not exist bin\x64\Debug\net6.0-windows\ GOTO vsRel
IF EXIST bin\x64\Debug\net6.0-windows\updater GOTO vsRel
cd %origDir%\bin\x64\Debug\net6.0-windows\
ECHO -----------------------------------
ECHO Moving files for x64 Debug in Visual Studio
ECHO -----------------------------------
mkdir updater
mkdir updater\x64
mkdir updater\x86
mkdir updater\ref
copy /B /Y "VCDiff.dll" "updater\VCDiff.dll"
copy /B /Y "YamlDotNet.dll" "updater\YamlDotNet.dll"
move /Y "TcNo-Acc-Switcher-Updater.runtimeconfig.json" "updater\TcNo-Acc-Switcher-Updater.runtimeconfig.json"
move /Y "TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json" "updater\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json"
move /Y "TcNo-Acc-Switcher-Updater.pdb" "updater\TcNo-Acc-Switcher-Updater.pdb"
copy /B /Y "TcNo-Acc-Switcher-Updater.dll" "updater\TcNo-Acc-Switcher-Updater.dll"
move /Y "TcNo-Acc-Switcher-Updater.deps.json" "updater\TcNo-Acc-Switcher-Updater.deps.json"
copy /B /Y "SevenZipExtractor.dll" "updater\SevenZipExtractor.dll"
move /Y "x86\7z.dll" "updater\x86\7z.dll"
move /Y "x64\7z.dll" "updater\x64\7z.dll"
copy /B /Y "ref\TcNo-Acc-Switcher-Updater.dll" "updater\ref\TcNo-Acc-Switcher-Updater.dll"
copy /B /Y "Newtonsoft.Json.dll" "updater\Newtonsoft.Json.dll"
RMDIR /Q/S "runtimes\linux-musl-x64"
RMDIR /Q/S "runtimes\linux-x64"
RMDIR /Q/S "runtimes\osx"
RMDIR /Q/S "runtimes\osx-x64"
RMDIR /Q/S "runtimes\unix"
RMDIR /Q/S "runtimes\win-arm64"
RMDIR /Q/S "runtimes\win-x86"
RMDIR /Q x64
RMDIR /Q x86
copy /B /Y "..\..\..\Installer\_First_Run_Installer.exe" "_First_Run_Installer.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Server.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Tray.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "updater\TcNo-Acc-Switcher-Updater.exe"
REN "wwwroot" "originalwwwroot"
cd %origDir%
GOTO end

REM Move updater files in Release folder (for Visual Studio):
:vsRel
REM SET VARIABLES
REM If SIGNTOOL environment variable is not set then try setting it to a known location
if "%SIGNTOOL%"=="" set SIGNTOOL=%ProgramFiles(x86)%\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe
Expand Down Expand Up @@ -88,19 +45,13 @@ mkdir updater\x64
mkdir updater\x86
mkdir updater\ref
copy /B /Y "..\..\..\Installer\_First_Run_Installer.exe" "_First_Run_Installer.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Server.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Tray.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Updater.exe"
REM Copy in Server runtimes that are missing for some reason...
xcopy ..\..\..\..\..\TcNo-Acc-Switcher-Server\bin\Release\net6.0\runtimes\win\lib\net6.0 runtimes\win\lib\net6.0 /E /H /C /I /Y

REM Signing
ECHO Signing binaries
echo %time%

REM GOTO :skipsign

(
start call ../../../../sign.bat "..\..\..\Wrapper\_Wrapper.exe"
start call ../../../../sign.bat "_First_Run_Installer.exe"
start call ../../../../sign.bat "TcNo-Acc-Switcher.exe"
start call ../../../../sign.bat "TcNo-Acc-Switcher.dll"
Expand All @@ -113,6 +64,20 @@ REM GOTO :skipsign
start call ../../../../sign.bat "TcNo-Acc-Switcher-Updater.dll"
) | set /P "="

REN "TcNo-Acc-Switcher.exe" "TcNo-Acc-Switcher_main.exe"
REN "TcNo-Acc-Switcher-Server.exe" "TcNo-Acc-Switcher-Server_main.exe"
REN "TcNo-Acc-Switcher-Tray.exe" "TcNo-Acc-Switcher-Tray_main.exe"
move /Y "TcNo-Acc-Switcher-Updater.exe" "updater\TcNo-Acc-Switcher-Updater_main.exe"

copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Server.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "TcNo-Acc-Switcher-Tray.exe"
copy /B /Y "..\..\..\Wrapper\_Wrapper.exe" "updater\TcNo-Acc-Switcher-Updater.exe"
copy /B /Y "_First_Run_Installer.exe" "updater\_First_Run_Installer.exe"

REM Copy in Server runtimes that are missing for some reason...
xcopy ..\..\..\..\..\TcNo-Acc-Switcher-Server\bin\Release\net6.0\runtimes\win\lib\net6.0 runtimes\win\lib\net6.0 /E /H /C /I /Y

echo %time%

:skipsign
Expand All @@ -121,7 +86,6 @@ copy /B /Y "YamlDotNet.dll" "updater\YamlDotNet.dll"
move /Y "TcNo-Acc-Switcher-Updater.runtimeconfig.json" "updater\TcNo-Acc-Switcher-Updater.runtimeconfig.json"
move /Y "TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json" "updater\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json"
move /Y "TcNo-Acc-Switcher-Updater.pdb" "updater\TcNo-Acc-Switcher-Updater.pdb"
move /Y "TcNo-Acc-Switcher-Updater.exe" "updater\TcNo-Acc-Switcher-Updater.exe"
copy /B /Y "TcNo-Acc-Switcher-Updater.dll" "updater\TcNo-Acc-Switcher-Updater.dll"
move /Y "TcNo-Acc-Switcher-Updater.deps.json" "updater\TcNo-Acc-Switcher-Updater.deps.json"
copy /B /Y "SevenZipExtractor.dll" "updater\SevenZipExtractor.dll"
Expand Down Expand Up @@ -196,94 +160,5 @@ copy /b/v/y CEF\CefSharp.BrowserSubprocess.Core.dll TcNo-Acc-Switcher\runtimes\w


cd %origDir%
GOTO end



REM Move updater files in Debug folder (for GitHub Actions):
:ghDebug
IF NOT EXIST bin\Debug\net6.0-windows\ GOTO ghRel
IF EXIST bin\Debug\net6.0-windows\updater GOTO ghRel
cd %origDir%
ECHO -----------------------------------
ECHO Moving files for x64 Debug in GitHub
ECHO -----------------------------------
mkdir bin\Debug\net6.0-windows\updater
mkdir bin\Debug\net6.0-windows\updater\x64
mkdir bin\Debug\net6.0-windows\updater\x86
mkdir bin\Debug\net6.0-windows\updater\ref
copy /B /Y "bin\Debug\net6.0-windows\VCDiff.dll" "bin\Debug\net6.0-windows\updater\VCDiff.dll"
copy /B /Y "bin\Debug\net6.0-windows\YamlDotNet.dll" "bin\Debug\net6.0-windows\updater\YamlDotNet.dll"
move /Y "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Updater.runtimeconfig.json" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.runtimeconfig.json"
move /Y "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json"
move /Y "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Updater.pdb" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.pdb"
copy /B /Y "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Updater.dll" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.dll"
move /Y "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Updater.deps.json" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.deps.json"
copy /B /Y "bin\Debug\net6.0-windows\SevenZipExtractor.dll" "bin\Debug\net6.0-windows\updater\SevenZipExtractor.dll"
move /Y "bin\Debug\net6.0-windows\x86\7z.dll" "bin\Debug\net6.0-windows\updater\x86\7z.dll"
move /Y "bin\Debug\net6.0-windows\x64\7z.dll" "bin\Debug\net6.0-windows\updater\x64\7z.dll"
copy /B /Y "bin\Debug\net6.0-windows\ref\TcNo-Acc-Switcher-Updater.dll" "bin\Debug\net6.0-windows\updater\ref\TcNo-Acc-Switcher-Updater.dll"
copy /B /Y "bin\Debug\net6.0-windows\Newtonsoft.Json.dll" "bin\Debug\net6.0-windows\updater\Newtonsoft.Json.dll"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\linux-musl-x64"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\linux-x64"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\osx"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\osx-x64"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\unix"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\win-arm64"
RMDIR /Q/S "bin\Debug\net6.0-windows\runtimes\win-x86"
RMDIR /Q "bin\Release\net6.0-windows\x64"
RMDIR /Q "bin\Release\net6.0-windows\x86"
copy /B /Y "..\..\Installer\_First_Run_Installer.exe" "_First_Run_Installer.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Debug\net6.0-windows\TcNo-Acc-Switcher.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Server.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Debug\net6.0-windows\TcNo-Acc-Switcher-Tray.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Debug\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.exe"
xcopy ..\..\..\..\TcNo-Acc-Switcher-Server\bin\Release\net6.0\runtimes\win\lib\net6.0 net6.0-windows\runtimes\win\lib\net6.0 /E /H /C /I /Y
REN "wwwroot" "originalwwwroot"
cd %origDir%
GOTO end

REM Move updater files in Release folder (for GitHub Actions):
:ghRel
IF NOT EXIST bin\Release\net6.0-windows\ GOTO end
IF EXIST bin\Release\net6.0-windows\updater GOTO end
cd %origDir%
ECHO -----------------------------------
ECHO Moving files for x64 Release in GitHub
ECHO -----------------------------------
mkdir bin\Release\net6.0-windows\updater
mkdir bin\Release\net6.0-windows\updater\x64
mkdir bin\Release\net6.0-windows\updater\x86
mkdir bin\Release\net6.0-windows\updater\ref
copy /B /Y "bin\Release\net6.0-windows\VCDiff.dll" "bin\Release\net6.0-windows\updater\VCDiff.dll"
copy /B /Y "bin\Debug\net6.0-windows\YamlDotNet.dll" "bin\Debug\net6.0-windows\updater\YamlDotNet.dll"
move /Y "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Updater.runtimeconfig.json" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.runtimeconfig.json"
move /Y "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.runtimeconfig.dev.json"
move /Y "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Updater.pdb" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.pdb"
copy /B /Y "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Updater.dll" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.dll"
move /Y "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Updater.deps.json" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.deps.json"
copy /B /Y "bin\Release\net6.0-windows\SevenZipExtractor.dll" "bin\Release\net6.0-windows\updater\SevenZipExtractor.dll"
move /Y "bin\Release\net6.0-windows\x86\7z.dll" "bin\Release\net6.0-windows\updater\x86\7z.dll"
move /Y "bin\Release\net6.0-windows\x64\7z.dll" "bin\Release\net6.0-windows\updater\x64\7z.dll"
copy /B /Y "bin\Release\net6.0-windows\ref\TcNo-Acc-Switcher-Updater.dll" "bin\Release\net6.0-windows\updater\ref\TcNo-Acc-Switcher-Updater.dll"
copy /B /Y "bin\Release\net6.0-windows\Newtonsoft.Json.dll" "bin\Release\net6.0-windows\updater\Newtonsoft.Json.dll"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\linux-musl-x64"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\linux-x64"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\osx"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\osx-x64"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\unix"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\win-arm64"
RMDIR /Q/S "bin\Release\net6.0-windows\runtimes\win-x86"
RMDIR /Q "bin\Release\net6.0-windows\x64"
RMDIR /Q "bin\Release\net6.0-windows\x86"
copy /B /Y "..\..\Installer\_First_Run_Installer.exe" "_First_Run_Installer.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Release\net6.0-windows\TcNo-Acc-Switcher.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Server.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Release\net6.0-windows\TcNo-Acc-Switcher-Tray.exe"
copy /B /Y "..\..\Wrapper\_Wrapper.exe" "bin\Release\net6.0-windows\updater\TcNo-Acc-Switcher-Updater.exe"
xcopy ..\..\..\..\TcNo-Acc-Switcher-Server\bin\Release\net6.0\runtimes\win\lib\net6.0 net6.0-windows\runtimes\win\lib\net6.0 /E /H /C /I /Y
REN "wwwroot" "originalwwwroot"
cd %origDir%
GOTO end

:end
2 changes: 1 addition & 1 deletion TcNo-Acc-Switcher-Globals/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Globals
#pragma warning disable CA2211 // Non-constant fields should not be visible - This is necessary due to it being a launch parameter.
public static bool VerboseMode;
#pragma warning restore CA2211 // Non-constant fields should not be visible
public static readonly string Version = "2021-12-06_00";
public static readonly string Version = "2021-12-07_00";
public static readonly string[] PlatformList = { "Steam", "Origin", "Ubisoft", "BattleNet", "Epic", "Riot", "Discord" };

#region LOGGER
Expand Down
4 changes: 2 additions & 2 deletions TcNo-Acc-Switcher-Server/Resources/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ Installer_TotalSize: "Total download size: ~{size} MB"
Installer_AnyKeyStart: Press any key to start download...
Runtime_WebView2: Microsoft WebView2 Runtime
Runtime_Desktop: Microsoft .NET 5 Desktop Runtime
Runtime_ASP: Microsoft Microsoft ASP.NET Core 5.0 Runtime
Runtime_ASP: Microsoft Microsoft ASP.NET Core 6.0 Runtime
Installer_FailedFolder: "Failed to create folder:"
Installer_FailedWV: "Failed to download and install Microsoft WebView2 Runtime. To download: 1. Click the link below: {link} 2. Click 'Download Hosting Bundle' under Run server apps."
Installer_FailedDR: "Failed to download and install .NET 5 Desktop Runtime. Please download it here:"
Installed_FailedASP: "Failed to download and install ASP.NET Core 5.0 Runtime. To download: 1. Click the link below: {link} 2. Click 'Download x64' under Run Desktop apps."
Installed_FailedASP: "Failed to download and install ASP.NET Core 6.0 Runtime. To download: 1. Click the link below: {link} 2. Click 'Download x64' under Run Desktop apps."
Installer_Ready: "One or more are ready for install. If and when prompted if you would like to install, click 'Yes'."
Installer_PressStart: Press any key to start install...
Installer_VerifyMin: "Verify you meet the minimum recommended requirements:"
Expand Down
36 changes: 0 additions & 36 deletions TcNo-Acc-Switcher-Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public class Startup
{
public Startup(IConfiguration configuration)
{
Console.Title = @"TcNo Account Switcher - Server";
IconChanger.SetConsoleIcon();

Configuration = configuration;
}

Expand Down Expand Up @@ -125,37 +122,4 @@ private static void MoveIfFileExists(string f)
File.Delete(Path.Join(Globals.AppDataFolder, f));
}
}

internal class IconChanger
{
// Based on https://stackoverflow.com/a/59897483/5165437
public static void SetConsoleIcon()
{
try
{
if (!OperatingSystem.IsWindows()) return;
var path = Path.Join(Globals.AppDataFolder, "originalwwwroot\\prog_icons\\program.ico");
if (!File.Exists(path)) path = Path.Join(Globals.AppDataFolder, "wwwroot\\prog_icons\\program.ico");
if (!File.Exists(path)) return;
var icon = new System.Drawing.Icon(path);
SetWindowIcon(icon);
}
catch (Exception)
{
//
}
}

[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, IntPtr lParam);

private static void SetWindowIcon(System.Drawing.Icon icon)
{
if (!OperatingSystem.IsWindows()) return;
// 0x0080 is SETICON
var mwHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
var result01 = SendMessage(mwHandle, (int)0x0080, 0, icon.Handle);
var result02 = SendMessage(mwHandle, (int)0x0080, 1, icon.Handle);
}
}
}
32 changes: 16 additions & 16 deletions _Updater_Wrapper/_Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,33 @@ int main(int argc, char* argv[])
if (!min_webview_met || !min_desktop_runtime_met || !min_aspcore_met)
{
// Launch installer to get these!
std::string back_path = getOperatingPath();
std::cout << "LAST: " << back_path.find("updater\\") << std::endl;
if (back_path.find("updater\\") <= back_path.length()) back_path += +"..\\"; // Go back a folder if in updater folder.
std::string self_path = getOperatingPath();
std::string s_args("net " + self);
exec_program(std::wstring(back_path.begin(), back_path.end()), L"_First_Run_Installer.exe", std::wstring(s_args.begin(), s_args.end()));
exec_program(std::wstring(self_path.begin(), self_path.end()), L"_First_Run_Installer.exe", std::wstring(s_args.begin(), s_args.end()));
}
else
{
std::string p = '"' + getOperatingPath();
if (p.back() != '\\') p += '\\';
p += self + ".dll\"";
std::string operating_path = getOperatingPath();
const std::string exe_name = self + "_main.exe";

std::string dotnet = dotnet_path();
std::cout << "Running: dotnet " << self << ".dll " << std::endl;

std::string full_path = operating_path,
args;
if (full_path.back() != '\\') full_path += '\\';
full_path += exe_name;

std::cout << "Running: " << exe_name << std::endl;

std::vector<char> buffer_temp;

for (int i = 1; i < argc; ++i)
p = p + " " + argv[i];

std::cout << dotnet << "dotnet.exe" << std::endl << p;
args += " " + static_cast<std::string>(argv[i]);

// Show window if running Server.
bool show_window = false;
if (self.find("Server") != std::string::npos || self.find("server") != std::string::npos) show_window = true;
std::cout << "FULL PATH: " << full_path << std::endl;

exec_program(std::wstring(dotnet.begin(), dotnet.end()), L"dotnet.exe", std::wstring(p.begin(), p.end()), show_window);
exec_program(std::wstring(operating_path.begin(), operating_path.end()),
std::wstring(exe_name.begin(), exe_name.end()),
std::wstring(args.begin(), args.end()));
}

exit(1);
Expand Down

0 comments on commit be87582

Please sign in to comment.