Skip to content

Commit

Permalink
fix spelling issues and random port
Browse files Browse the repository at this point in the history
  • Loading branch information
kdcllc committed Mar 25, 2019
1 parent 79058ca commit 1c90ccf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/AppAuthentication/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class Constants

public static readonly string MsiAppServiceSecretEnv = "MSI_SECRET";

public static readonly string MsiContinerUrl = "host.docker.internal";
public static readonly string MsiContainerUrl = "host.docker.internal";

public static readonly string HostUrl = "http://{0}:{1}/";

Expand Down
2 changes: 1 addition & 1 deletion src/AppAuthentication/EnvironmentHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Task StartAsync(CancellationToken cancellationToken)
{
Environment.SetEnvironmentVariable(
Constants.MsiAppServiceEndpointEnv,
$"{string.Format(Constants.HostUrl,Constants.MsiContinerUrl,_options.Port)}{Constants.MsiEndpoint}",
$"{string.Format(Constants.HostUrl,Constants.MsiContainerUrl,_options.Port)}{Constants.MsiEndpoint}",
EnvironmentVariableTarget.User);

Environment.SetEnvironmentVariable(
Expand Down
15 changes: 13 additions & 2 deletions src/AppAuthentication/Helpers/ConsoleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,19 @@ internal static string GetUserSecretsId()

internal static int GetRandomUnusedPort()
{
var listener = new TcpListener(IPAddress.Loopback, 5050);
listener.Start();
TcpListener listener = null;

try
{
listener = new TcpListener(IPAddress.Loopback, 5050);
listener.Start();
}
catch (Exception)
{
listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
}

var port = ((IPEndPoint)listener.LocalEndpoint).Port;
listener.Stop();
return port;
Expand Down
2 changes: 1 addition & 1 deletion src/AppAuthentication/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private async Task<int> OnExecuteAsync()
var builderConfig = new WebHostBuilderOptions
{
Authority = Authority,
HostingEnviroment = !string.IsNullOrWhiteSpace(HostingEnviroment) ? HostingEnviroment : "Development",
HostingEnvironment = !string.IsNullOrWhiteSpace(HostingEnviroment) ? HostingEnviroment : "Development",
Resource = !string.IsNullOrWhiteSpace(Resource) ? Resource : "https://vault.azure.net/",
Verbose = Verbose,
ConfigFile = ConfigFile,
Expand Down
4 changes: 2 additions & 2 deletions src/AppAuthentication/WebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static WebHostBuilder CreateDefaultBuilder(WebHostBuilderOptions option
{
var builder = new WebHostBuilder();

builder.UseEnvironment(options.HostingEnviroment);
builder.UseEnvironment(options.HostingEnvironment);
var fullPath = Directory.GetCurrentDirectory();

if (!string.IsNullOrWhiteSpace(Path.GetDirectoryName(options.ConfigFile)))
Expand All @@ -38,7 +38,7 @@ internal static WebHostBuilder CreateDefaultBuilder(WebHostBuilderOptions option

// appsettings file or others
config.AddJsonFile(Path.Combine(fullPath, $"{(defaultConfigName).Split(".")[0]}.json"), optional: true)
.AddJsonFile(Path.Combine(fullPath, $"{(defaultConfigName).Split(".")[0]}.{options.HostingEnviroment}.json"), optional: true);
.AddJsonFile(Path.Combine(fullPath, $"{(defaultConfigName).Split(".")[0]}.{options.HostingEnvironment}.json"), optional: true);

if (options.Arguments != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/AppAuthentication/WebHostBuilderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ internal class WebHostBuilderOptions
public string Authority { get; set; }

/// <summary>
/// Specify environment.
/// Specify Environment.
/// </summary>
public string HostingEnviroment { get; set; }
public string HostingEnvironment { get; set; }

public bool Verbose { get; set; }

Expand Down

0 comments on commit 1c90ccf

Please sign in to comment.