mirror of https://github.com/abpframework/abp.git
4 changed files with 53 additions and 6 deletions
@ -0,0 +1,35 @@ |
|||
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps |
|||
{ |
|||
public class ChangeLocalhostPortStep : ProjectBuildPipelineStep |
|||
{ |
|||
public string LaunchSettingsFilePath { get; } |
|||
public int[] PortNumbers { get; } |
|||
|
|||
public ChangeLocalhostPortStep( |
|||
string launchSettingsFilePath, |
|||
params int[] portNumbers) |
|||
{ |
|||
Check.NotNullOrEmpty(portNumbers, nameof(portNumbers)); |
|||
|
|||
LaunchSettingsFilePath = launchSettingsFilePath; |
|||
PortNumbers = portNumbers; |
|||
} |
|||
|
|||
public override void Execute(ProjectBuildContext context) |
|||
{ |
|||
var launchSettings = context.GetFile(LaunchSettingsFilePath); |
|||
var randomPort = RandomHelper.GetRandom(50001, 59990); |
|||
var newContent = launchSettings.Content; |
|||
|
|||
for (var i = 0; i < PortNumbers.Length; i++) |
|||
{ |
|||
newContent = newContent.Replace( |
|||
PortNumbers[i].ToString(), |
|||
(randomPort + i).ToString() |
|||
); |
|||
} |
|||
|
|||
launchSettings.SetContent(newContent); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue