推广您的产品

外观
官网地址:https://visualstudio.microsoft.com
1、安装Tye
dotnet tool install -g Microsoft.Tye --version "0.12.0-*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
2、安装EasyRun
点击顶部菜单栏:拓展 -> 管理拓展 -> 浏览选项卡搜索EasyRun点击安装
3、配置EasyRun
模板项目,在01.SlnFiles/MyCompanyName.MyProjectName.sln.EasyRun.json
中配置
{
"SettingsId": "2b14968a-f3ca-4849-bcad-5d4f210d2960",
"Profiles": [
{
"Name": "Default",
"LoggingTargetType": 0,
"LoggingPath": "./.logs",
"LoggerUrl": null,
"UseTye": true,
"TyePort": 10000,
"Filter": ".Host",
"Services": [
{
"ServiceType": 0,
"Name": "MyCompanyName.MyGateway.Host",
"TyeName": null,
"ProjectFile": "gateways\\MyCompanyName.MyGateway\\MyCompanyName.MyGateway.Host.csproj",
"DefaultSelected": true,
"Bindings": "::16010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "MyCompanyName.MyIMServer.Host",
"TyeName": null,
"ProjectFile": "modules\\im\\MyCompanyName.MyIMServer\\MyCompanyName.MyIMServer.Host.csproj",
"DefaultSelected": true,
"Bindings": "::17010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "MyCompanyName.MySys",
"TyeName": null,
"ProjectFile": "modules\\sys\\MyCompanyName.MySys\\MyCompanyName.MySys.Host.csproj",
"DefaultSelected": true,
"Bindings": "::18010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "MyCompanyName.MyBiz",
"TyeName": null,
"ProjectFile": "modules\\biz\\MyCompanyName.MyBiz\\MyCompanyName.MyBiz.Host.csproj",
"DefaultSelected": true,
"Bindings": "::18020",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "MyCompanyName.MyMem",
"TyeName": null,
"ProjectFile": "modules\\mem\\MyCompanyName.MyMem\\MyCompanyName.MyMem.Host.csproj",
"DefaultSelected": true,
"Bindings": "::18030",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
}
]
}
]
}
源码项目,在01.sln/ZhonTai.sln.EasyRun.json
中配置
{
"SettingsId": "2b14968a-f3ca-4849-bcad-5d4f210d2960",
"Profiles": [
{
"Name": "Default",
"LoggingTargetType": 0,
"LoggingPath": "./.logs",
"LoggerUrl": null,
"UseTye": true,
"TyePort": 10000,
"Filter": ".Host",
"Services": [
{
"ServiceType": 0,
"Name": "ZhonTai.Gateway.Yarp.Host",
"TyeName": null,
"ProjectFile": "gateways\\ZhonTai.Gateway.Yarp.Host\\ZhonTai.Gateway.Yarp.Host.csproj",
"DefaultSelected": true,
"Bindings": "::16010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "ZhonTai.IMServer.Host",
"TyeName": null,
"ProjectFile": "modules\\im\\ZhonTai.IMServer.Host\\ZhonTai.IMServer.Host.csproj",
"DefaultSelected": true,
"Bindings": "::17010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
},
{
"ServiceType": 0,
"Name": "ZhonTai.Admin.Host",
"TyeName": null,
"ProjectFile": "modules\\admin\\ZhonTai.Admin.Host\\ZhonTai.Admin.Host.csproj",
"DefaultSelected": true,
"Bindings": "::18010",
"Arguments": null,
"EnvVariables": null,
"Replicas": 1
}
]
}
]
}
4、打开EasyRun
点击顶部菜单栏:视图
-> 其他窗口 -> EasyRun,打开EasyRun窗口
5、运行项目
在EasyRun
选项卡勾选要运行的项目,点击Tye
按钮运行,再次点击Tye
按钮停止运行
6、调试项目
在EasyRun
选项卡运行的项目中,选择要调试的项目点击Debugger
按钮开启调试
点击顶部菜单栏:工具 -> 选项 -> 调试 -> 常规,取消启用“仅我的代码”
,勾选启用源服务器支持
--> 点击确定
F12进入NuGet程序包源码,在要调试的代码处设置断点,点击Debugger
按钮开启调试
默认情况下,Visual Studio 2022等较新版本的“文件”菜单中可能未显示“高级保存选项”,需手动添加
此时“文件”菜单中会显示 “高级保存选项”菜单项,打开高级保存选项窗口,可设置保存编码、换行符等
命名样式标题:private-fields-with-underscore
必填前缀: _
大写: 驼峰式大写命名
在构造参数string name
处使用快捷键Alt + Enter
,选择创建字段“_name”并赋值
选项
生成代码如下:
public class ModuleService : BaseService, IDynamicApi
{
private readonly string _name;
public ModuleService(string name)
{
_name = name;
}
}