{ "cells": [ { "cell_type": "markdown", "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" } }, "source": [ "# HttpClient 测试" ] }, { "cell_type": "markdown", "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" }, "vscode": { "languageId": "polyglot-notebook" } }, "source": [ "## 1、引用项目Dll" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" }, "vscode": { "languageId": "polyglot-notebook" } }, "outputs": [], "source": [ "//引用项目\n", "#r \"./Publish/HttpClientStudy.Core/HttpClientStudy.Core.dll\"\n", "\n", "//执行C#工具方法\n", "using HttpClientStudy.Core.Utilities;\n", "var result = CmdUtility.RunCmd(\"dir\");\n", "Console.WriteLine(result);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 启动项目" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "pwsh" }, "polyglot_notebook": { "kernelName": "pwsh" }, "vscode": { "languageId": "polyglot-notebook" } }, "outputs": [], "source": [ "#启动已发布的WebApi项目\n", "Start-Process -FilePath \"Publish\\HttpClientStudy.WebApp\\HttpClientStudy.WebApp.exe\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "pwsh" }, "polyglot_notebook": { "kernelName": "pwsh" }, "vscode": { "languageId": "polyglot-notebook" } }, "outputs": [], "source": [ "# 编译并启动WebApi项目\n", "Start-Process -FilePath dotnet -ArgumentList \"run --project ..\\HttpClientStudy.WebApp\\HttpClientStudy.WebApp.csproj\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "pwsh" }, "polyglot_notebook": { "kernelName": "pwsh" }, "vscode": { "languageId": "polyglot-notebook" } }, "outputs": [], "source": [ "# 关闭项目进程\n", "$WebAppProcName =\"HttpClientStudy.WebApp\";\n", "$WebAppProc = Get-Process $WebAppProcName -ErrorAction Ignore\n", "if($null -eq $WebAppProc)\n", "{\n", " Write-Host \"进程没有找到,可能已经\"\n", "}\n", "else {\n", " $WebAppProc.Kill();\n", " Write-Host \"$WebAppProcName 进程已退出\"\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" }, "vscode": { "languageId": "polyglot-notebook" } }, "outputs": [], "source": [ "var basePath = System.Environment.CurrentDirectory;\n", "\n", "var filePath =\"./Docs/a.txt\";\n", " \n", "var full = System.IO.Path.GetFullPath(filePath,basePath);\n", "\n", "Console.WriteLine(full);" ] } ], "metadata": { "kernelspec": { "display_name": ".NET (C#)", "language": "C#", "name": ".net-csharp" }, "language_info": { "name": "python" }, "polyglot_notebook": { "kernelInfo": { "defaultKernelName": "csharp", "items": [ { "aliases": [], "name": "csharp" } ] } } }, "nbformat": 4, "nbformat_minor": 2 }