EnvironmentHelper 增加 Rease 编译 只允许生产环境
This commit is contained in:
1 parent
7f15eb9c0b
commit
e6660f03f6
3 files changed
+7
-2
No files matched your search
@@ -19,7 +19,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\KJD Cef138\Bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
// 获取环境描述
|
||||
|
||||
Reference in new issue
Block a user