Skip to content

Commit 13afca4

Browse files
committed
# Conflicts: # eFormAPI/Installation/AllowMultipleVersionsBundle/Resources/Eform Angular Frontend.exe # eFormAPI/Installation/Bundle/maininstaller.msi
2 parents 565aab1 + 367177a commit 13afca4

File tree

849 files changed

+797
-53045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

849 files changed

+797
-53045
lines changed
Binary file not shown.

eFormAPI/Installation/Bundle/Bundle.wxs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
<Fragment>
1313
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Node.js" Variable="NODEJS" Win64="yes" Value="InstallPath"/>
14-
<util:RegistrySearch Root="HKLM" Key="Software\GitForWindows" Win64="yes" Variable="GIT" Value="InstallPath"/>
1514
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\IIS Extensions\URL Rewrite" Variable="URLREWRITE" Value="Version"/>
1615
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\IIS Extensions\Application Request Routing" Variable="ARR" Value="Version"/>
1716

1817
<PackageGroup Id="ReqiredPackages">
19-
<ExePackage Id="Git" DisplayName="Git" Cache="no" Compressed="yes" Permanent="yes" Vital="yes" SourceFile=".\Git-2.14.2-64-bit.exe" InstallCondition="NOT GIT" InstallCommand="/VERYSILENT"/>
2018
<MsiPackage Id="NodeJS" DisplayName="NodeJS" Cache="no" Compressed="yes" DisplayInternalUI="no" Permanent="yes" Vital="yes" SourceFile=".\node-v8.6.0-x64.msi" InstallCondition="NOT NODEJS"/>
2119
<MsiPackage Id="URLRewrite" DisplayName="URL Rewrite" Cache="no" Compressed="yes" DisplayInternalUI="no" Permanent="yes" Vital="yes" SourceFile=".\rewrite_amd64.msi" ForcePerMachine="yes" InstallCondition="NOT URLREWRITE"/>
2220
<MsiPackage Id="ARR" DisplayName="Application Request Routing" Cache="no" Compressed="yes" DisplayInternalUI="no" Permanent="yes" Vital="yes" SourceFile=".\requestRouter_amd64.msi" ForcePerMachine="yes" InstallCondition="NOT ARR"/>
-37 MB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-16"?>
2+
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<DeployedProjects />
4+
<DirectoryMappings />
5+
<FileMappings />
6+
<DeploySymbols>false</DeploySymbols>
7+
<DeployExternalLocalizations>false</DeployExternalLocalizations>
8+
</Configuration>

eFormAPI/Installation/Bundle/InstallBundle.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
</ProjectReference>
4848
</ItemGroup>
4949
<ItemGroup>
50-
<Content Include="Git-2.14.2-64-bit.exe" />
5150
<Content Include="HyperlinkTheme.xml" />
51+
<Content Include="InstallBundle.wax" />
5252
<Content Include="maininstaller.msi" />
5353
<Content Include="node-v8.6.0-x64.msi" />
5454
<Content Include="requestRouter_amd64.msi" />
11.6 MB
Binary file not shown.

eFormAPI/Installation/CustomActions/CustomAction.cs

Lines changed: 60 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -66,66 +66,62 @@ public static ActionResult GetAPIsListCA(Session session)
6666
public static ActionResult InstallCA(Session session)
6767
{
6868
Session = session;
69-
7069
try
7170
{
72-
ResetProgressBar(session, 10);
73-
7471
if (session.CustomActionData["INSTMODE"] != "Install")
7572
return ActionResult.Success;
7673

77-
var tmpDir = session.CustomActionData["INSTALLFOLDER"] + "microtingTemp";
74+
ResetProgressBar(session, 10);
7875

76+
var installFolder = session.CustomActionData["INSTALLFOLDER"];
7977
var customerNumber = session.CustomActionData["CUSTOMERNUMBER"];
8078
var domain = session.CustomActionData["DOMAINNAME"];
8179

82-
session.Log("Get latest product version called");
83-
GetProductLatestVersion(tmpDir);
80+
session.Log("Get web api port");
81+
var webApiPort = GetWebApiPort();
82+
var webApiName = $"{customerNumber}_{domain}_{webApiPort}";
8483
IncrementProgressBar(session);
8584

86-
var webApiPort = GetWebApiPort();
87-
var nextUiPort = webApiPort-2000;
88-
var uiName = $"{customerNumber}_{domain}_client_{nextUiPort}";
89-
var uiIisDir = session.CustomActionData["INSTALLFOLDER"] + uiName;
90-
var angularSolutionLocation = $@"{tmpDir}\eform-client";
91-
session.Log("Build Angullar app task started");
92-
BuildAngularApp(uiIisDir, angularSolutionLocation);
85+
session.Log("Get ui port");
86+
var uiPort = webApiPort-2000;
87+
var uiName = $"{customerNumber}_{domain}_client_{uiPort}";
9388
IncrementProgressBar(session);
9489

95-
var webApiLocation = $@"{tmpDir}\eFormAPI\eFormAPI";
96-
var webApiName = $"{customerNumber}_{domain}_{webApiPort}";
97-
var webApiIisDir = session.CustomActionData["INSTALLFOLDER"] + webApiName;
98-
session.Log("Build WebAPI called");
90+
var clientLocation = Path.Combine(installFolder, uiName);
91+
var webApiLocation = Path.Combine(installFolder, webApiName);
9992

100-
BuildWebApi(webApiLocation, webApiIisDir);
93+
session.Log("Set proper names to folders");
94+
RenameFolders(installFolder, webApiLocation, clientLocation);
10195
IncrementProgressBar(session);
96+
97+
session.Log("Build Angullar app task started");
98+
BuildAngularApp(clientLocation);
99+
IncrementProgressBar(session);
100+
102101
session.Log("Host WebAPI called");
103-
HostWebApi(webApiName, webApiPort, webApiIisDir);
102+
HostWebApi(webApiName, webApiPort, webApiLocation);
104103
IncrementProgressBar(session);
105104

106105
session.Log("RunAngularAsWinService called");
107-
RunAngularAsWinService(webApiPort, nextUiPort, uiIisDir, uiName);
106+
RunAngularAsWinService(webApiPort, uiPort, clientLocation, uiName);
108107
IncrementProgressBar(session);
109108

110109
session.Log("HostAngularApp called");
111-
HostAngularApp(uiIisDir, domain, uiName);
110+
HostAngularApp(clientLocation, domain, uiName);
112111
IncrementProgressBar(session);
113112

114113
session.Log("AddRedirectionRules called");
115-
AddRedirectionRules(uiName, $"http://localhost:{nextUiPort}");
114+
AddRedirectionRules(uiName, $"http://localhost:{uiPort}");
116115
IncrementProgressBar(session);
117116

118117
session.Log("SaveInstances called");
119118
SaveInstances(webApiName);
120119
IncrementProgressBar(session);
121120

122121
if (session.CustomActionData["GENERATESSL"]== "1")
123-
RunProcess($@"{tmpDir}\eFormAPI\Installation\letsencrypt\letsencrypt.exe", $"--plugin manual --manualhost {uiName} --webroot {session.CustomActionData["INSTALLFOLDER"].TrimEnd('\\')}");
124-
125-
IncrementProgressBar(session);
122+
RunProcess(Path.Combine(installFolder, "letsencrypt\\letsencrypt.exe"), $"--plugin manual --manualhost {uiName} --webroot {session.CustomActionData["INSTALLFOLDER"].TrimEnd('\\')}");
126123

127-
session.Log("Clear temp dir called");
128-
DeleteDirectory(tmpDir);
124+
DeleteDirectory(Path.Combine(installFolder, "letsencrypt"));
129125
IncrementProgressBar(session);
130126

131127
return ActionResult.Success;
@@ -162,55 +158,56 @@ public static ActionResult UpdateCA(Session session)
162158

163159
try
164160
{
165-
ResetProgressBar(session, 8);
166161
if (session.CustomActionData["INSTMODE"] != "Update")
167162
return ActionResult.Success;
168163

164+
ResetProgressBar(session, 8);
165+
169166
var domainName = session.CustomActionData["DOMAINNAME"];
170167
var api = domainName.Split('_');
171168
var domain = api[1];
172169
var customerNumber = api.First();
173170
var apiPort = int.Parse(api.Last());
174171
var uiPort = apiPort - 2000;
175172

176-
var installDir = GetInstallDirrectory(domainName);
177-
var tmpDir = Path.Combine(installDir + "microtingTemp");
173+
var siteDir = GetInstallDirrectory(domainName);
178174

179175
// stop sites
180176
ControlSites(customerNumber, domain, apiPort, uiPort, false);
181177
IncrementProgressBar(session);
182178

183-
GetProductLatestVersion(tmpDir);
184-
IncrementProgressBar(session);
185-
186179
// client update
187180
var uiName = $"{customerNumber}_{domain}_client_{uiPort}";
188-
var uiIisDir = Path.Combine(installDir + uiName);
181+
var uiIisDir = Path.Combine(siteDir + uiName);
182+
var webApiLocation = Path.Combine(siteDir, domainName);
189183

190184
RunProcess(@"sc", $"stop eformangular{uiName.Replace(".", "")}.exe");
191185
Thread.Sleep(1000);
192186
RunProcess(@"C:\Program Files\nodejs\node.exe", "svc.js uninstall", uiIisDir);
193187
IncrementProgressBar(session);
194188

195-
BuildAngularApp(uiIisDir, tmpDir + "\\eform-client");
196-
IncrementProgressBar(session);
189+
DeleteDirectory(webApiLocation);
190+
DeleteDirectory(uiIisDir);
191+
192+
session.Log("Set proper names to folders");
193+
194+
DirectoryCopy(Path.Combine(session.CustomActionData["INSTALLFOLDER"], "eform-api"), webApiLocation);
195+
DirectoryCopy(Path.Combine(session.CustomActionData["INSTALLFOLDER"], "eform-client"), uiIisDir);
197196

198-
199-
RunAngularAsWinService(apiPort, uiPort, uiIisDir, uiName);
200197
IncrementProgressBar(session);
201198

202-
// api update
203-
var webApiName = $"{customerNumber}_{domain}_{apiPort}";
204-
var webApiIisDir = Path.Combine(installDir + webApiName);
205-
BuildWebApi(tmpDir + "\\eFormAPI\\eFormAPI", webApiIisDir);
199+
session.Log("Build Angullar app task started");
200+
BuildAngularApp(uiIisDir);
206201
IncrementProgressBar(session);
207202

208-
ControlSites(customerNumber, domain, apiPort, uiPort, true);
203+
session.Log("RunAngularAsWinService called");
204+
RunAngularAsWinService(apiPort, uiPort, uiIisDir, uiName);
209205
IncrementProgressBar(session);
210206

211-
DeleteDirectory(tmpDir);
207+
ControlSites(customerNumber, domain, apiPort, uiPort, true);
212208
IncrementProgressBar(session);
213209

210+
DeleteDirectory(session.CustomActionData["INSTALLFOLDER"]);
214211
return ActionResult.Success;
215212
}
216213
catch (Exception ex)
@@ -313,40 +310,21 @@ private static string GetServiceList()
313310
return ui;
314311
}
315312

316-
private static void GetProductLatestVersion(string directory)
313+
private static void RenameFolders(string location, string apiName, string uiName)
317314
{
318-
RunProcess("git", $"clone https://github.com/microting/eform-angular-frontend.git {directory}");
315+
Directory.Move(Path.Combine(location, "eform-api"), apiName);
316+
Directory.Move(Path.Combine(location, "eform-client"), uiName);
319317
}
320318

321-
private static void BuildAngularApp(string appLocation, string appSolutionLocation)
319+
private static void BuildAngularApp(string appLocation)
322320
{
323-
if (Directory.Exists(appLocation))
324-
DeleteDirectory(appLocation);
325-
326-
Session.Log("BuildAngularApp -> DirectoryCopy");
327-
DirectoryCopy(appSolutionLocation, appLocation);
328-
329321
Session.Log("BuildAngularApp -> npm install");
330322
RunProcess(@"C:\Program Files\nodejs\npm.cmd", "install", appLocation);
331323

332324
Session.Log("BuildAngularApp -> npm run build");
333325
RunProcess(@"C:\Program Files\nodejs\npm.cmd", "run build", appLocation);
334326
}
335327

336-
private static void BuildWebApi(string solutionLocation, string iisDir)
337-
{
338-
var parentDir = new DirectoryInfo(solutionLocation).Parent.FullName;
339-
RunProcess(parentDir + @"\installation\nuget\nuget.exe", "restore -PackagesDirectory packages", parentDir);
340-
RunProcess(parentDir + @"\installation\msbuild\msbuild.exe", $@"{solutionLocation}\eFormAPI.Web.csproj /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:Platform=x64", killChildProcess: true);
341-
342-
if (Directory.Exists(iisDir))
343-
DeleteDirectory(iisDir);
344-
345-
var newLocation = Directory.CreateDirectory(iisDir);
346-
347-
DirectoryCopy($@"{solutionLocation}\bin\Release\PublishOutput", newLocation.FullName);
348-
}
349-
350328
private static void HostWebApi(string webApiName, int port, string iisDir)
351329
{
352330
using (var serverManager = new ServerManager())
@@ -496,49 +474,6 @@ private static void CreateAppPool(ServerManager serverManager, string name)
496474
serverManager.CommitChanges();
497475
}
498476

499-
static void RunProcess(string fileName, string arguments, string workingDirrectory = null, bool killChildProcess = false)
500-
{
501-
using (var process = Process.Start(new ProcessStartInfo
502-
{
503-
FileName = fileName,
504-
Arguments = arguments,
505-
WindowStyle = ProcessWindowStyle.Hidden,
506-
UseShellExecute = false,
507-
WorkingDirectory = workingDirrectory
508-
}))
509-
{
510-
process.WaitForExit();
511-
if (killChildProcess)
512-
KillAllProcessesSpawnedBy((UInt32)process.Id);
513-
}
514-
}
515-
516-
private static void KillAllProcessesSpawnedBy(UInt32 parentProcessId)
517-
{
518-
519-
// NOTE: Process Ids are reused!
520-
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
521-
"SELECT * " +
522-
"FROM Win32_Process " +
523-
"WHERE ParentProcessId=" + parentProcessId);
524-
ManagementObjectCollection collection = searcher.Get();
525-
if (collection.Count > 0)
526-
{
527-
foreach (var item in collection)
528-
{
529-
UInt32 childProcessId = (UInt32)item["ProcessId"];
530-
if ((int)childProcessId != Process.GetCurrentProcess().Id)
531-
{
532-
KillAllProcessesSpawnedBy(childProcessId);
533-
534-
Process childProcess = Process.GetProcessById((int)childProcessId);
535-
childProcess.Kill();
536-
Thread.Sleep(1000);
537-
}
538-
}
539-
}
540-
}
541-
542477
private static void DirectoryCopy(string sourceDirName, string destDirName)
543478
{
544479
// Get the subdirectories for the specified directory.
@@ -575,6 +510,21 @@ private static void DirectoryCopy(string sourceDirName, string destDirName)
575510

576511
}
577512

513+
static void RunProcess(string fileName, string arguments, string workingDirrectory = null)
514+
{
515+
using (var process = Process.Start(new ProcessStartInfo
516+
{
517+
FileName = fileName,
518+
Arguments = arguments,
519+
WindowStyle = ProcessWindowStyle.Hidden,
520+
UseShellExecute = false,
521+
WorkingDirectory = workingDirrectory
522+
}))
523+
{
524+
process.WaitForExit();
525+
}
526+
}
527+
578528
private static void ControlSites(string customerNumber, string domain, int apiPort, int uiPort, bool shouldSiteBeStarted)
579529
{
580530
using (var serverManager = new ServerManager())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-16"?>
2+
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<DeployedProjects>
4+
<string>eFormAPI\eFormAPI.Web.csproj</string>
5+
</DeployedProjects>
6+
<DirectoryMappings>
7+
<Item Key="" Value="INSTALLFOLDER" />
8+
<Item Key="bin" Value="ProgramFilesFolder" />
9+
</DirectoryMappings>
10+
<FileMappings />
11+
<DeploySymbols>false</DeploySymbols>
12+
<DeployExternalLocalizations>false</DeployExternalLocalizations>
13+
</Configuration>

eFormAPI/Installation/MainInstaller/MainInstaller.wixproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<Compile Include="Product.wxs" />
3434
</ItemGroup>
3535
<ItemGroup>
36+
<Content Include="MainInstaller.wax" />
3637
<Content Include="MicrotingEULA.rtf" />
3738
</ItemGroup>
3839
<ItemGroup>
@@ -46,6 +47,14 @@
4647
</WixExtension>
4748
</ItemGroup>
4849
<ItemGroup>
50+
<ProjectReference Include="..\..\eFormAPI\eFormAPI.Web.csproj">
51+
<Name>eFormAPI.Web</Name>
52+
<Project>{54404cf9-a407-4f55-bc26-b243099e29a8}</Project>
53+
<Private>True</Private>
54+
<DoNotHarvest>True</DoNotHarvest>
55+
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
56+
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
57+
</ProjectReference>
4958
<ProjectReference Include="..\CustomActions\CustomActions.csproj">
5059
<Name>CustomActions</Name>
5160
<Project>{768280ff-c359-4e58-8b5c-1f682b41cc24}</Project>

eFormAPI/Installation/MainInstaller/MaintenanceTypeModifiedDlg.wxs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Condition Action="disable">NOUI</Condition>
1919
<Publish Property="WixUI_InstallMode" Value="Update">1</Publish>
2020
<Publish Property="INSTMODE" Value="Update">1</Publish>
21+
<Publish Property="INSTALLFOLDER" Value="C:\tmp" >1</Publish>
2122
</Control>
2223
<Control Id="Remove" Type="PushButton" X="98" Y="185" Width="139" Height="33" Text="&amp;Remove" >
2324
<Condition Action="disable">NOUI</Condition>

0 commit comments

Comments
 (0)