diff --git a/src/Surging.Core/Surging.Core.CPlatform/Configurations/RuntimeEnvironment.cs b/src/Surging.Core/Surging.Core.CPlatform/Configurations/RuntimeEnvironment.cs new file mode 100644 index 000000000..fdc85ad79 --- /dev/null +++ b/src/Surging.Core/Surging.Core.CPlatform/Configurations/RuntimeEnvironment.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Surging.Core.CPlatform.Configurations +{ + public enum RuntimeEnvironment + { + Development = 0, + + Test, + + Staging, + + Production, + } +} diff --git a/src/Surging.Core/Surging.Core.CPlatform/Configurations/SurgingServerOptions.cs b/src/Surging.Core/Surging.Core.CPlatform/Configurations/SurgingServerOptions.cs index 177fd5750..2c96ffd77 100644 --- a/src/Surging.Core/Surging.Core.CPlatform/Configurations/SurgingServerOptions.cs +++ b/src/Surging.Core/Surging.Core.CPlatform/Configurations/SurgingServerOptions.cs @@ -47,5 +47,7 @@ public partial class SurgingServerOptions: ServiceCommand public string NotRelatedAssemblyFiles { get; set; } public string RelatedAssemblyFiles { get; set; } = ""; + + public RuntimeEnvironment Environment { get; set; } = RuntimeEnvironment.Production; } } diff --git a/src/Surging.Core/Surging.Core.CPlatform/ServiceHostBuilderExtensions.cs b/src/Surging.Core/Surging.Core.CPlatform/ServiceHostBuilderExtensions.cs index 4d99e80c9..9663cf61e 100644 --- a/src/Surging.Core/Surging.Core.CPlatform/ServiceHostBuilderExtensions.cs +++ b/src/Surging.Core/Surging.Core.CPlatform/ServiceHostBuilderExtensions.cs @@ -29,6 +29,7 @@ public static IServiceHostBuilder UseServer(this IServiceHostBuilder hostBuilder { return hostBuilder.MapServices(async mapper => { + Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", AppConfig.ServerOptions.Environment.ToString()); BuildServiceEngine(mapper); await mapper.Resolve().SetServiceCommandsAsync(); string serviceToken = mapper.Resolve().GeneratorToken(token);