diff --git a/AppDemo/.dockerignore b/AppDemo/.dockerignore
new file mode 100644
index 0000000..3729ff0
--- /dev/null
+++ b/AppDemo/.dockerignore
@@ -0,0 +1,25 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/AppDemo/AppDemo.sln b/AppDemo/AppDemo.sln
new file mode 100644
index 0000000..9ba88ce
--- /dev/null
+++ b/AppDemo/AppDemo.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31911.196
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppDemo", "AppDemo\AppDemo.csproj", "{91A256A6-962E-4D61-887C-2E7BAD206002}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {91A256A6-962E-4D61-887C-2E7BAD206002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {91A256A6-962E-4D61-887C-2E7BAD206002}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {91A256A6-962E-4D61-887C-2E7BAD206002}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {91A256A6-962E-4D61-887C-2E7BAD206002}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {92E0A98C-A330-485F-B3CA-F3DEC02824B2}
+ EndGlobalSection
+EndGlobal
diff --git a/AppDemo/AppDemo/App.config b/AppDemo/AppDemo/App.config
new file mode 100644
index 0000000..49cc43e
--- /dev/null
+++ b/AppDemo/AppDemo/App.config
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/AppDemo/AppDemo/AppDemo.csproj b/AppDemo/AppDemo/AppDemo.csproj
new file mode 100644
index 0000000..f3d2391
--- /dev/null
+++ b/AppDemo/AppDemo/AppDemo.csproj
@@ -0,0 +1,33 @@
+
+
+
+ Exe
+ net5.0
+ Linux
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
diff --git a/AppDemo/AppDemo/Dockerfile b/AppDemo/AppDemo/Dockerfile
new file mode 100644
index 0000000..46376c7
--- /dev/null
+++ b/AppDemo/AppDemo/Dockerfile
@@ -0,0 +1,20 @@
+#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
+
+FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
+WORKDIR /app
+
+FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+WORKDIR /src
+COPY ["AppDemo/AppDemo.csproj", "AppDemo/"]
+RUN dotnet restore "AppDemo/AppDemo.csproj"
+COPY . .
+WORKDIR "/src/AppDemo"
+RUN dotnet build "AppDemo.csproj" -c Release -o /app/buildQ--
+
+FROM build AS publish
+RUN dotnet publish "AppDemo.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "AppDemo.dll"]
\ No newline at end of file
diff --git a/AppDemo/AppDemo/Program.cs b/AppDemo/AppDemo/Program.cs
new file mode 100644
index 0000000..95866cc
--- /dev/null
+++ b/AppDemo/AppDemo/Program.cs
@@ -0,0 +1,68 @@
+using Microsoft.Extensions.Configuration;
+
+using System;
+using System.Diagnostics;
+using System.Threading;
+
+namespace AppDemo
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ var netcoreEnvironmentName = "DOTNET_ENVIRONMENT";
+ var environmentValue = Environment.GetEnvironmentVariable(netcoreEnvironmentName);
+
+
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{environmentValue}.json", optional: true, reloadOnChange: true)
+ .AddEnvironmentVariables()
+ .AddCommandLine(args);
+
+ var configurationRoot = builder.Build();
+
+ var jsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings()
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ };
+
+ while (true)
+ {
+ Console.WriteLine("当前运行环境");
+ Console.WriteLine($"运行模式:{(Debugger.IsAttached ? "调试模式" : "发布模式")}");
+ Console.WriteLine($"args参数:{string.Join(",", args ?? new string[0])}");
+
+ var environmetValue = configurationRoot.GetValue(netcoreEnvironmentName);
+ Console.WriteLine($"配置项中,{netcoreEnvironmentName}={environmetValue}");
+
+ if (args != null)
+ {
+ foreach (var arg in args)
+ {
+ Console.WriteLine($"args传参数:{arg}");
+ if (!string.IsNullOrWhiteSpace(arg))
+ {
+ var argList = arg.Split('=');
+ if (argList.Length == 2)
+ {
+ Console.WriteLine($"配置管理中,{argList[0]}的值为:{configurationRoot.GetValue(argList[0])}");
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("---------------------------------------------------------------------");
+ Console.WriteLine();
+
+ //var configText = Newtonsoft.Json.JsonConvert.SerializeObject(configurationRoot.GetChildren(),jsonSerializerSettings);
+ //Console.WriteLine("当前配置:");
+ //Console.WriteLine(configText);
+ //Console.WriteLine("---------------------------------------------------------------------");
+ //Console.WriteLine();
+ Thread.Sleep(5000);
+ }
+ }
+ }
+}
diff --git a/AppDemo/AppDemo/Properties/launchSettings.json b/AppDemo/AppDemo/Properties/launchSettings.json
new file mode 100644
index 0000000..b4c1f6d
--- /dev/null
+++ b/AppDemo/AppDemo/Properties/launchSettings.json
@@ -0,0 +1,13 @@
+{
+ "profiles": {
+ "AppDemo": {
+ "commandName": "Project",
+ "environmentVariables": {
+ "DOTNET_ENVIRONMENT": "Development"
+ }
+ },
+ "Docker": {
+ "commandName": "Docker"
+ }
+ }
+}
\ No newline at end of file
diff --git a/AppDemo/AppDemo/appsettings.Development.json b/AppDemo/AppDemo/appsettings.Development.json
new file mode 100644
index 0000000..7bd8da1
--- /dev/null
+++ b/AppDemo/AppDemo/appsettings.Development.json
@@ -0,0 +1,3 @@
+{
+ "urls": ["https://www.baidu.com","cn.bing.com"]
+}
\ No newline at end of file
diff --git a/AppDemo/AppDemo/appsettings.json b/AppDemo/AppDemo/appsettings.json
new file mode 100644
index 0000000..deb7bd6
--- /dev/null
+++ b/AppDemo/AppDemo/appsettings.json
@@ -0,0 +1,12 @@
+{
+ "NETCORE": "Development",
+ "urls": [ "https://www.baidu.com", "cn.bing.com" ],
+ "exclude": [
+ "**/bin",
+ "**/bower_components",
+ "**/jspm_packages",
+ "**/node_modules",
+ "**/obj",
+ "**/platforms"
+ ]
+}
\ No newline at end of file
diff --git a/AppDemo/Dockerfile b/AppDemo/Dockerfile
new file mode 100644
index 0000000..8ad2984
--- /dev/null
+++ b/AppDemo/Dockerfile
@@ -0,0 +1,20 @@
+#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
+
+FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
+WORKDIR /app
+
+FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+WORKDIR /src
+COPY ["AppDemo/AppDemo.csproj", "AppDemo/"]
+RUN dotnet restore "AppDemo/AppDemo.csproj"
+COPY . .
+WORKDIR "/src/AppDemo"
+RUN dotnet build "AppDemo.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "AppDemo.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "AppDemo.dll"]
\ No newline at end of file
diff --git a/Demo/NetAppDemo/App/AppDemo.dll b/Demo/NetAppDemo/App/AppDemo.dll
index bf67e4c..371f624 100644
Binary files a/Demo/NetAppDemo/App/AppDemo.dll and b/Demo/NetAppDemo/App/AppDemo.dll differ
diff --git a/Demo/NetAppDemo/App/appsettings.Development.json b/Demo/NetAppDemo/App/appsettings.Development.json
index b9dea1e..7bd8da1 100644
--- a/Demo/NetAppDemo/App/appsettings.Development.json
+++ b/Demo/NetAppDemo/App/appsettings.Development.json
@@ -1,11 +1,3 @@
{
- "urls": ["https://www.baidu.com","cn.bing.com"],
- "exclude": [
- "**/bin",
- "**/bower_components",
- "**/jspm_packages",
- "**/node_modules",
- "**/obj",
- "**/platforms"
- ]
+ "urls": ["https://www.baidu.com","cn.bing.com"]
}
\ No newline at end of file
diff --git a/Demo/NetAppDemo/App/appsettings.json b/Demo/NetAppDemo/App/appsettings.json
index b9dea1e..deb7bd6 100644
--- a/Demo/NetAppDemo/App/appsettings.json
+++ b/Demo/NetAppDemo/App/appsettings.json
@@ -1,5 +1,6 @@
{
- "urls": ["https://www.baidu.com","cn.bing.com"],
+ "NETCORE": "Development",
+ "urls": [ "https://www.baidu.com", "cn.bing.com" ],
"exclude": [
"**/bin",
"**/bower_components",
diff --git a/Demo/NetAppDemo/Dockerfile b/Demo/NetAppDemo/Dockerfile
index d2fff48..c00bc28 100644
--- a/Demo/NetAppDemo/Dockerfile
+++ b/Demo/NetAppDemo/Dockerfile
@@ -1,5 +1,7 @@
+# 直接复制发布文件
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
-WORKDIR /app
-COPY ./publish .
-
+WORKDIR /app
+ENV DOTNET_ENVIRONMENT="Dockerfile_env"
+COPY ./App .
+# CMD [ "DOTNET_ENVIRONMENT=Dockerfile_cmd" ]
ENTRYPOINT [ "dotnet","AppDemo.dll" ]
\ No newline at end of file