@@ -44,7 +44,7 @@ public ServiceCommand()
4444 }
4545
4646 [ CommandMethod ]
47- [ CommandMethodProperty ( nameof ( Port ) , nameof ( ServiceName ) , nameof ( DisplayName ) , nameof ( Comment ) ) ]
47+ [ CommandMethodProperty ( nameof ( Port ) , nameof ( ServiceName ) , nameof ( DisplayName ) , nameof ( Comment ) , nameof ( HttpPort ) ) ]
4848 public void Install ( string path )
4949 {
5050 var basePath = new DirectoryInfo ( path ) . FullName ;
@@ -91,16 +91,24 @@ public string DisplayName
9191 set ;
9292 }
9393
94+ [ CommandProperty ]
95+ public int ? HttpPort
96+ {
97+ get ;
98+ set ;
99+ }
100+
94101 public override bool IsEnabled => Environment . OSVersion . Platform == PlatformID . Win32NT ;
95102
96103 private void InstallService ( string exeFilename , string basePath )
97104 {
98105 var pathArg = string . Format ( "/PATH={0}" , basePath ) ;
99106 var portArg = string . Format ( "/PORT={0}" , this . Port ) ;
107+ var httpPortArgs = string . Format ( "/HTTPPORT={0}" , this . HttpPort ?? AddressUtility . GetDefaultHttpPort ( this . Port ) ) ;
100108 var displayNameArg = string . Format ( "/DisplayName={0}" , this . DisplayName ) ;
101109 var serviceNameArg = string . Format ( "/ServiceName={0}" , this . ServiceName ) ;
102110 var comment = string . Format ( "/Comment={0}" , this . Comment ) ;
103- var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , comment } ;
111+ var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , comment , httpPortArgs } ;
104112 var installer = new AssemblyInstaller ( exeFilename , commandLineOptions ) ;
105113
106114 installer . Install ( null ) ;
@@ -111,9 +119,10 @@ private void UninstallService(string exeFilename, string basePath)
111119 {
112120 var pathArg = string . Format ( "/PATH={0}" , basePath ) ;
113121 var portArg = string . Format ( "/PORT={0}" , this . Port ) ;
122+ var httpPortArgs = string . Format ( "/HTTPPORT={0}" , this . HttpPort ?? AddressUtility . GetDefaultHttpPort ( this . Port ) ) ;
114123 var displayNameArg = string . Format ( "/DisplayName={0}" , this . DisplayName ) ;
115124 var serviceNameArg = string . Format ( "/ServiceName={0}" , this . ServiceName ) ;
116- var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg } ;
125+ var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , httpPortArgs } ;
117126 var installer = new AssemblyInstaller ( exeFilename , commandLineOptions )
118127 {
119128 UseNewContext = true
0 commit comments