EnvironmentHelper 增加 Rease 编译 只允许生产环境

This commit is contained in:
chfei committed 2026-08-06 15:04:05 +08:00
1 parent 7f15eb9c0b
commit e6660f03f6
3 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\KJD Cef138\Bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -10,7 +10,7 @@
<FallbackCulture>zh-CN</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ProjectFiles</ProjectView>
<ActiveDebugProfile>Production</ActiveDebugProfile>
<ActiveDebugProfile>Development</ActiveDebugProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
+5
View File
@@ -29,6 +29,10 @@ public class EnvironmentHelper
private static string DetermineEnvironment()
{
#if RELEASE
// Release 构建:只允许生产环境,不允许其他环境
return "Production";
#else
// 1. 检查环境变量
var envVar = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ??
Environment.GetEnvironmentVariable("ENVIRONMENT");
@@ -49,6 +53,7 @@ public class EnvironmentHelper
// 4. 默认返回 Production
return "Production";
#endif
}
// 获取环境描述