# 一、指定项目发布程序
dotnet publish -c release .\Admin.Api\Admin.Api.csproj -o ..\.PublishFiles\Admin.Api
1
# 二、通过 web.config 配置发布程序的环境
项目根目录添加 web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Admin.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" />
<!--Development-->
<!--Staging-->
<!--Production-->
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 三、通过 Windows 批处理发布程序(参考)
color B
del .PublishFiles\*.* /s /q
dotnet restore
dotnet build
cd Blog.Core.Api
dotnet publish -o ..\Blog.Core.Api\bin\Debug\netcoreapp3.1\
md ..\.PublishFiles
xcopy ..\Blog.Core.Api\bin\Debug\netcoreapp3.1\*.* ..\.PublishFiles\ /s /e
echo "Successfully!!!! ^ please see the file .PublishFiles"
cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19