发布 asp net core 3.1 应用程序时如何定义应用程序设置属性
How to define appsetting properties when publishing an asp net core 3.1 app
我有一个使用 rider 和 asp net core 3.1
制作的 webapi 应用程序
在我项目的 Properties 文件夹下,我有一个 launchSettings.json 似乎是添加所有信息以使我的应用程序以我喜欢的方式启动的地方。这是我的 launchSettings.json:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": false
},
"profiles": {
"AuthWebApi": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://0.0.0.0:5137"
}
}
}
当我想发布我的应用程序时,我的问题来了。一切顺利,但是当我用 donet 执行我的 dll 时,它从端口 5000 开始,而不是我在 launchSettings.json (5137) 中配置的端口。我猜这是因为我定义的配置只在调试时生效。但我不确定。
我知道我可以在 运行 我的二进制文件时使用 url 参数让它监听我想要的端口,但我更喜欢在 launchsettings.json 中进行所有配置。
这可能吗?您如何处理发布商应用的启动设置?
launchSettings.json
用于 only for development environment:
The launchSettings.json file:
- Is only used on the local development machine.
- Is not deployed.
- contains profile settings.
要设置 production/staging 环境,您可以使用环境变量 and/or 配置文件。
您的问题也有答案
您可以使用以下命令:
dotnet run --urls=http://localhost:5001/
我有一个使用 rider 和 asp net core 3.1
制作的 webapi 应用程序在我项目的 Properties 文件夹下,我有一个 launchSettings.json 似乎是添加所有信息以使我的应用程序以我喜欢的方式启动的地方。这是我的 launchSettings.json:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": false
},
"profiles": {
"AuthWebApi": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://0.0.0.0:5137"
}
}
}
当我想发布我的应用程序时,我的问题来了。一切顺利,但是当我用 donet 执行我的 dll 时,它从端口 5000 开始,而不是我在 launchSettings.json (5137) 中配置的端口。我猜这是因为我定义的配置只在调试时生效。但我不确定。
我知道我可以在 运行 我的二进制文件时使用 url 参数让它监听我想要的端口,但我更喜欢在 launchsettings.json 中进行所有配置。
这可能吗?您如何处理发布商应用的启动设置?
launchSettings.json
用于 only for development environment:
The launchSettings.json file:
- Is only used on the local development machine.
- Is not deployed.
- contains profile settings.
要设置 production/staging 环境,您可以使用环境变量 and/or 配置文件。
您的问题也有答案
您可以使用以下命令:
dotnet run --urls=http://localhost:5001/