This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"dotnet run 命令使用\n",
"=================="
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## 使用经典 Powershell (Powershell 5及以下) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [],
"source": [
"#!powershell\n",
"\n",
"# 查看 powershell 版本信息\n",
"$PSVersionTable.PSVersion"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## 使用新版跨平台 Powershell (Powershell 6及以上)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [],
"source": [
"#!pwsh\n",
"\n",
"# 查看 Powershell 版本\n",
"$PSVersionTable.PSVersion"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## 使用 dotnet run 命令运行 项目或程序\n",
"格式:\n",
" dotnet run [applicationArguments] [options]"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 显示帮助信息"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [],
"source": [
"#!pwsh\n",
"dotnet run --help"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 运行当前目录下的项目"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [],
"source": [
"#!pwsh\n",
"\n",
"# 先进入项目目录\n",
"cd ..\\DotnetDemo.CApp\n",
"\n",
"dotnet run"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 指定项目文件\n",
"使用 --project path/xxx.csproj 参数\n",
"dotnet run --project csproj文件相对或绝对路"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "pwsh"
},
"polyglot_notebook": {
"kernelName": "pwsh"
}
},
"outputs": [],
"source": [
"#!pwsh\n",
"\n",
"dotnet run --project ..\\DotnetDemo.CApp\\DotnetDemo.CApp.csproj"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 编译方式参数 -c --configurartion Debug|Realese"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "pwsh"
},
"polyglot_notebook": {
"kernelName": "pwsh"
}
},
"outputs": [],
"source": [
"#!powershell\n",
"\n",
"# Debug 模式\n",
"dotnet run --project \"..\\DotnetDemo.CApp\\DotnetDemo.CApp.csproj\" -c Debug"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "pwsh"
},
"polyglot_notebook": {
"kernelName": "pwsh"
}
},
"outputs": [],
"source": [
"#!powershell\n",
"\n",
"# Reasele 模式\n",
"dotnet run --project \"..\\DotnetDemo.CApp\\DotnetDemo.CApp.csproj\" -c Release"