@@ -34,39 +34,55 @@ public async Task<SimulationResult> RunAsync(
3434 Log ( $ "STEP 2: Preparing { config . AppDirectory } ", progress ) ;
3535 Directory . CreateDirectory ( config . AppDirectory ) ;
3636
37- // 3. Compile test apps to .exe
38- Log ( "STEP 3: Compiling test apps" , progress ) ;
37+ // 3. Ensure test apps are available
38+ Log ( "STEP 3: Preparing test apps" , progress ) ;
3939 var toolsDir = AppDomain . CurrentDomain . BaseDirectory ;
40- var clientProj = Path . Combine ( toolsDir , ".." , ".." , ".." , ".." , "test_app" , "Client" , "ClientSample.csproj" ) ;
41- var upgradeProj = Path . Combine ( toolsDir , ".." , ".." , ".." , ".." , "test_app" , "Upgrade" , "UpgradeSample.csproj" ) ;
42-
43- // Normalize paths
44- clientProj = Path . GetFullPath ( clientProj ) ;
45- upgradeProj = Path . GetFullPath ( upgradeProj ) ;
46-
47- if ( ! File . Exists ( clientProj ) )
48- throw new FileNotFoundException ( $ "Client project not found at { clientProj } ") ;
49- if ( ! File . Exists ( upgradeProj ) )
50- throw new FileNotFoundException ( $ "Upgrade project not found at { upgradeProj } ") ;
51-
52- var exeDir = Path . Combine ( toolsDir , "test_app" ) ;
53- Directory . CreateDirectory ( exeDir ) ;
54-
55- Log ( " Compiling Client.exe..." , progress ) ;
56- await DotNetPublishAsync ( clientProj , exeDir ) ;
57- Log ( $ " Client.exe → { exeDir } ", progress ) ;
58-
59- Log ( " Compiling Upgrade.exe..." , progress ) ;
60- await DotNetPublishAsync ( upgradeProj , exeDir ) ;
61- Log ( $ " Upgrade.exe → { exeDir } ", progress ) ;
62-
63- // Copy compiled apps into app directory (where the update will run)
6440 var clientDest = Path . Combine ( config . AppDirectory , "Client.exe" ) ;
65- File . Copy ( Path . Combine ( exeDir , "ClientSample .exe" ) , clientDest , true ) ;
41+ var upgradeDest = Path . Combine ( config . AppDirectory , "Upgrade .exe" ) ;
6642
67- var upgradeExe = Path . Combine ( exeDir , "UpgradeSample.exe" ) ;
68- File . Copy ( upgradeExe , Path . Combine ( config . AppDirectory , "Upgrade.exe" ) , true ) ;
69- Log ( $ " Upgrade.exe → { config . AppDirectory } ", progress ) ;
43+ if ( File . Exists ( clientDest ) && File . Exists ( upgradeDest ) )
44+ {
45+ Log ( " Test apps already cached, skipping" , progress ) ;
46+ }
47+ else
48+ {
49+ // Strategy 1: bundled exes (release package)
50+ var bundledDir = Path . Combine ( toolsDir , "test_app_exe" ) ;
51+ if ( Directory . Exists ( bundledDir ) &&
52+ File . Exists ( Path . Combine ( bundledDir , "ClientSample.exe" ) ) &&
53+ File . Exists ( Path . Combine ( bundledDir , "UpgradeSample.exe" ) ) )
54+ {
55+ Log ( " Copying bundled test apps..." , progress ) ;
56+ File . Copy ( Path . Combine ( bundledDir , "ClientSample.exe" ) , clientDest , true ) ;
57+ File . Copy ( Path . Combine ( bundledDir , "UpgradeSample.exe" ) , upgradeDest , true ) ;
58+ Log ( $ " Client.exe → { config . AppDirectory } ", progress ) ;
59+ Log ( $ " Upgrade.exe → { config . AppDirectory } ", progress ) ;
60+ }
61+ else
62+ {
63+ // Strategy 2: compile from source (dev environment)
64+ var clientProj = Path . GetFullPath ( Path . Combine ( toolsDir , ".." , ".." , ".." , ".." , "test_app" , "Client" , "ClientSample.csproj" ) ) ;
65+ var upgradeProj = Path . GetFullPath ( Path . Combine ( toolsDir , ".." , ".." , ".." , ".." , "test_app" , "Upgrade" , "UpgradeSample.csproj" ) ) ;
66+
67+ if ( ! File . Exists ( clientProj ) || ! File . Exists ( upgradeProj ) )
68+ throw new FileNotFoundException ( "Test apps not found. Run in dev environment or use a release build that includes test_app_exe." ) ;
69+
70+ var exeDir = Path . Combine ( toolsDir , "test_app" ) ;
71+ Directory . CreateDirectory ( exeDir ) ;
72+
73+ Log ( " Compiling Client.exe..." , progress ) ;
74+ await DotNetPublishAsync ( clientProj , exeDir ) ;
75+ Log ( $ " Client.exe → { exeDir } ", progress ) ;
76+
77+ Log ( " Compiling Upgrade.exe..." , progress ) ;
78+ await DotNetPublishAsync ( upgradeProj , exeDir ) ;
79+ Log ( $ " Upgrade.exe → { exeDir } ", progress ) ;
80+
81+ File . Copy ( Path . Combine ( exeDir , "ClientSample.exe" ) , clientDest , true ) ;
82+ File . Copy ( Path . Combine ( exeDir , "UpgradeSample.exe" ) , upgradeDest , true ) ;
83+ Log ( $ " Copied to { config . AppDirectory } ", progress ) ;
84+ }
85+ }
7086
7187 // 4. Start server
7288 Log ( "STEP 4: Starting local server" , progress ) ;
0 commit comments