@@ -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,23 @@ public string DisplayName
9191 set ;
9292 }
9393
94+ [ CommandProperty ]
95+ public int ? HttpPort {
96+ get ;
97+ set ;
98+ }
99+
94100 public override bool IsEnabled => Environment . OSVersion . Platform == PlatformID . Win32NT ;
95101
96102 private void InstallService ( string exeFilename , string basePath )
97103 {
98104 var pathArg = string . Format ( "/PATH={0}" , basePath ) ;
99105 var portArg = string . Format ( "/PORT={0}" , this . Port ) ;
106+ var httpPortArgs = string . Format ( "/HTTPPORT={0}" , this . HttpPort ?? AddressUtility . GetDefaultHttpPort ( this . Port ) ) ;
100107 var displayNameArg = string . Format ( "/DisplayName={0}" , this . DisplayName ) ;
101108 var serviceNameArg = string . Format ( "/ServiceName={0}" , this . ServiceName ) ;
102109 var comment = string . Format ( "/Comment={0}" , this . Comment ) ;
103- var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , comment } ;
110+ var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , comment , httpPortArgs } ;
104111 var installer = new AssemblyInstaller ( exeFilename , commandLineOptions ) ;
105112
106113 installer . Install ( null ) ;
@@ -111,9 +118,10 @@ private void UninstallService(string exeFilename, string basePath)
111118 {
112119 var pathArg = string . Format ( "/PATH={0}" , basePath ) ;
113120 var portArg = string . Format ( "/PORT={0}" , this . Port ) ;
121+ var httpPortArgs = string . Format ( "/HTTPPORT={0}" , this . HttpPort ?? AddressUtility . GetDefaultHttpPort ( this . Port ) ) ;
114122 var displayNameArg = string . Format ( "/DisplayName={0}" , this . DisplayName ) ;
115123 var serviceNameArg = string . Format ( "/ServiceName={0}" , this . ServiceName ) ;
116- var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg } ;
124+ var commandLineOptions = new string [ ] { pathArg , portArg , displayNameArg , serviceNameArg , httpPortArgs } ;
117125 var installer = new AssemblyInstaller ( exeFilename , commandLineOptions )
118126 {
119127 UseNewContext = true
0 commit comments