1414using System . Security . Principal ;
1515using System . Management . Automation ;
1616using System . Net . NetworkInformation ;
17+ using System . Xml . Linq ;
1718
1819namespace CustomActions
1920{
@@ -368,6 +369,14 @@ private static void CopyProtectedData(Session session, string installFolder)
368369 File . Delete ( Path . Combine ( dst , "System.Security.Cryptography.ProtectedData.dll" ) ) ;
369370 }
370371 File . Copy ( Path . Combine ( installFolder , @"bin\System.Security.Cryptography.ProtectedData.dll" ) , Path . Combine ( dst , "System.Security.Cryptography.ProtectedData.dll" ) ) ;
372+
373+ dst = Path . Combine ( installFolder , @"bin\runtimes\win\lib\netcoreapp2.1" ) ;
374+ Directory . CreateDirectory ( dst ) ;
375+ if ( File . Exists ( Path . Combine ( dst , "System.Data.SqlClient.dll" ) ) )
376+ {
377+ File . Delete ( Path . Combine ( dst , "System.Data.SqlClient.dll" ) ) ;
378+ }
379+ File . Copy ( Path . Combine ( installFolder , @"bin\System.Data.SqlClient.dll" ) , Path . Combine ( dst , "System.Data.SqlClient.dll" ) ) ;
371380 }
372381
373382 [ CustomAction ]
@@ -397,6 +406,7 @@ public static ActionResult UpdateCA(Session session)
397406
398407 // stop sites
399408 ControlSites ( customerNumber , domain , apiPort , uiPort , false ) ;
409+ Thread . Sleep ( 10000 ) ;
400410 IncrementProgressBar ( session ) ;
401411
402412 // client update
@@ -449,8 +459,9 @@ public static ActionResult UpdateCA(Session session)
449459
450460 session . Log ( "AddImageHandlers called" ) ;
451461 AddImageHandlers ( webApiName , webApiLocation ) ;
452- IncrementProgressBar ( session ) ;
462+ AddAspNetCoreSection ( webApiName , webApiLocation ) ;
453463
464+ IncrementProgressBar ( session ) ;
454465
455466 session . Log ( "RunAngularAsWinService called" ) ;
456467 RunAngularAsWinService ( apiPort , uiPort , uiIisDir , uiName ) ;
@@ -775,21 +786,7 @@ private static void AddImageHandlers(string siteName, string webdataLocation)
775786 ConfigurationSection handlersSection = config . GetSection ( "system.webServer/handlers" ) ;
776787 ConfigurationElementCollection handlersCollection = handlersSection . GetCollection ( ) ;
777788
778- ConfigurationSection webserverSection = config . GetSection ( "system.webserver" ) ;
779- foreach ( ConfigurationElement ele in webserverSection . ChildElements )
780- {
781- if ( ele . ChildElements . Count < 1 )
782- {
783- webserverSection . GetCollection ( ) . Remove ( ele ) ;
784- }
785- }
786-
787- ConfigurationElement new_ele = webserverSection . GetCollection ( ) . CreateElement ( "aspNetCore" ) ;
788- new_ele [ "processPath" ] = "dotnet" ;
789- new_ele [ "arguments" ] = Path . Combine ( webdataLocation , @"bin\eFormAPI.Web.dll" ) ;
790- new_ele [ "stdoutLogEnabled" ] = "false" ;
791- new_ele [ "stdoutLogFile" ] = Path . Combine ( webdataLocation , @"bin\logs\stdout" ) ;
792- webserverSection . GetCollection ( ) . Add ( new_ele ) ;
789+ ConfigurationSection webserverSection = null ;
793790
794791 List < ConfigurationElement > toRemoveElements = new List < ConfigurationElement > ( ) ;
795792
@@ -814,9 +811,9 @@ private static void AddImageHandlers(string siteName, string webdataLocation)
814811 handlersCollection . Add ( ele ) ;
815812
816813 }
817- catch
814+ catch ( Exception ex )
818815 {
819-
816+ MessageBox . Show ( "jpgHandlerMissing ex is : " + ex . Message + "stacktrace : " + ex . StackTrace ) ;
820817 }
821818
822819 try
@@ -872,6 +869,29 @@ private static void AddImageHandlers(string siteName, string webdataLocation)
872869 }
873870 }
874871
872+ private static void AddAspNetCoreSection ( string siteName , string webdataLocation )
873+ {
874+
875+ XDocument xmlFile = XDocument . Load ( Path . Combine ( webdataLocation , "web.config" ) ) ;
876+ var query = from c in xmlFile . Elements ( "configuration" ) . Elements ( "location" ) . Elements ( "system.webServer" ) select c ;
877+
878+ query . First ( ) ;
879+
880+ if ( query . Elements ( "aspNetCore" ) . Count ( ) != 1 )
881+ {
882+
883+ XElement xElement = new XElement ( "aspNetCore" ) ;
884+ xElement . SetAttributeValue ( "processPath" , "dotnet" ) ;
885+ xElement . SetAttributeValue ( "arguments" , Path . Combine ( webdataLocation , @"bin\eFormAPI.Web.dll" ) ) ;
886+ xElement . SetAttributeValue ( "stdoutLogEnabled" , "false" ) ;
887+ xElement . SetAttributeValue ( "stdoutLogFile" , Path . Combine ( webdataLocation , @"bin\logs\stdout" ) ) ;
888+ query . First ( ) . Add ( xElement ) ;
889+
890+ xmlFile . Save ( Path . Combine ( webdataLocation , "web.config" ) ) ;
891+ }
892+ }
893+
894+
875895 private static void AddRedirectionRules ( string siteName , string uiServiceLink )
876896 {
877897 using ( ServerManager serverManager = new ServerManager ( ) )
@@ -1021,6 +1041,9 @@ private static void DirectoryCopy(string sourceDirName, string destDirName, bool
10211041 if ( file . Name . Equals ( "Web.config" , StringComparison . InvariantCultureIgnoreCase ) && File . Exists ( temppath ) )
10221042 continue ;
10231043
1044+ if ( file . Name . Equals ( "appsettings.json" , StringComparison . InvariantCultureIgnoreCase ) && File . Exists ( temppath ) )
1045+ continue ;
1046+
10241047 if ( File . Exists ( temppath ) && ! overrideFile )
10251048 continue ;
10261049
0 commit comments