# 运行环境
# SDK、RunTime、Hosting Bundle的区别
- SDK 是用来开发的,内部捆绑了Runtime运行时
- 但是如何只想运行NetCore以上版本项目的话,只需要在服务器中安装 Runtime 运行时即可
- Hosting Bundle是Runtime在Windows平台上运行的托管包,支持IIS
# 脚本命令
初始化.net项目命令帮助:dotnet new --help
查看.net信息:dotnet --info
创建一个mvc项目:dotnet new mvc
运行新建的程序:dotnet run
自动编译修改:dotnet watch run
启动项目:
dotnet run --urls="https://*:8079" --ip="127.0.0.1" --port=8079
dotnet SyloneCore.dll --urls="https://*:8079" --ip="127.0.0.1" --port=8079
port 参数读取
public class IndexController:Controller{
private readonly ILogger<IndexController> _logger;
private readonly IConfiguration _configuration;
public IndexController(ILogger<IndexController> logger,IConfiguration configuration){
_logger=logger;
_configuration=configuration;
}
public IActionResult Index(){
ViewBag.port=_configuration["port"];
_logger.LogInformation("这里输出日志");
}
}
# 环境配置
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56372",
"sslPort": 44384 // 端口号改成0即为HTTP方式
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SyloneTestAPI": {
"commandName": "Project",
"dotnetRunMessages": "true",//是否显示运行状态信息
"launchBrowser": true,
"launchUrl": "swagger",//调整swagger的展示路径,需要和c.RoutePrefix一起设置
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_URLS": "https://localhost:5002" //配置地址
}
}
}
}
基础信息 →