zoukankan      html  css  js  c++  java
  • vs code 写C#心得

    !!!官方指南请访问:
    https://docs.microsoft.com/zh-cn/dotnet/core/index
    code runner 插件
    ————————————————————————————————————
    还是用命令行运行来的简便,不喜欢他的调试的配置,哭唧唧。
    dotnet new console -n test
    dotnet run
    ————————————————————————————————————
    如果要调试,你得先把这个文件夹加入到工作空间:

    然后,shift + command + p ,添加lauch.json tasks.json。

    ————————————————————————————————————
    举个例子:
    '''
    {
    "version": "2.0.0",
    "tasks": [
    {
    "label": "build",
    "command": "dotnet",
    "type": "process",
    "args": [
    "build",
    "({workspaceFolder}/ch4.csproj" ], "problemMatcher": ")msCompile"
    }
    ]
    }
    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    {
    "name": ".NET Core Launch (console)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build",
    "program": "({workspaceFolder}/bin/Debug/netcoreapp2.1/ch4.dll", "args": [], "cwd": "){workspaceFolder}",
    "console": "internalConsole",
    "stopAtEntry": false,
    "internalConsoleOptions": "openOnSessionStart"
    },
    {
    "name": ".NET Core Attach",
    "type": "coreclr",
    "request": "attach",
    "processId": "${command:pickProcess}"
    }
    ]
    }
    '''
    ————————————————————————————————————
    命令行方式:首先你得安装相关的扩展,根据其要求还得安装一个core
    安装之后,在vs code中打开terminal
    使用命令创建工程 dotnet new console -n test
    注意:加了-n 之后会创建一个文件夹名为test,不加则直接在当前目录建工程
    如果忘记了命令,可以 dotnet -h(还可以访问官方文档,地址在后面)
    '''
    dotnet -h
    .NET Command Line Tools (2.1.500)

    Usage: dotnet [sdk-options] [command] [command-options] [arguments]
    
    sdk-options:
      -d|--diagnostics  Enable diagnostic output.
      -h|--help         Show command line help.
      --info            Display .NET Core information.
      --list-runtimes   Display the installed runtimes.
      --list-sdks       Display the installed SDKs.
      --version         Display .NET Core SDK version in use.
    
    SDK commands:
      add               Add a package or reference to a .NET project.
      build             Build a .NET project.
      build-server      Interact with servers started by a build.
      clean             Clean build outputs of a .NET project.
      help              Show command line help.
      list              List project references of a .NET project.
      migrate           Migrate a project.json project to an MSBuild project.
      msbuild           Run Microsoft Build Engine (MSBuild) commands.
      new               Create a new .NET project or file.
      nuget             Provides additional NuGet commands.
      pack              Create a NuGet package.
      publish           Publish a .NET project for deployment.
      remove            Remove a package or reference from a .NET project.
      restore           Restore dependencies specified in a .NET project.
      run               Build and run a .NET project output.
      sln               Modify Visual Studio solution files.
      store             Store the specified assemblies in the runtime package store.
      test              Run unit tests using the test runner specified in a .NET project.
      tool              Install or manage tools that extend the .NET experience.
      vstest            Run Microsoft Test Engine (VSTest) commands.
    
    Additional commands from bundled tools:
      dev-certs         Create and manage development certificates.
      ef                Entity Framework Core command-line tools.
      sql-cache         SQL Server cache command-line tools.
      user-secrets      Manage development user secrets.
      watch             Start a file watcher that runs a command when files change.
    
    Run 'dotnet [command] --help' for more information on a command.
    

    '''
    使用命令运行工程 dotnet run
    如果要用vs code进行调试:
    按F5, 然后创建两个文件:launch.json 和 tasks.json
    注意要更改launch.json 中间的路径名,例如:"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"

    Attention:
    了解如何使用 dotnet-restore 命令还原依赖项和特定于项目的工具。
    restore : 修复; 归还; 交还; 使恢复
    软件开发工具包(缩写:SDK、外语全称:Software Development Kit)

    官方指南请访问:
    https://docs.microsoft.com/zh-cn/dotnet/core/index

    创建首个应用程序
    安装 .NET Core SDK 后,打开命令提示符。 键入以下 dotnet 命令以创建并运行 C# 应用程序。

    dotnet new console
    dotnet run
    您应看到以下输出:

    Hello World!

    摘要:
    dotnet new
    模板描述 模板名称 语言
    控制台应用程序 console [C#]、F#、VB
    类库 classlib [C#]、F#、VB
    单元测试项目 mstest [C#]、F#、VB
    xUnit 测试项目 xunit [C#]、F#、VB
    Razor 页 page [C#]
    MVC ViewImports viewimports [C#]
    MVC ViewStart viewstart [C#]
    ASP.NET Core 空 web [C#],F#
    ASP.NET Core Web 应用程序 (Model-View-Controller) mvc [C#],F#
    ASP.NET Core Web 应用程序 razor, webapp [C#]
    含 Angular 的 ASP.NET Core angular [C#]
    含 React.js 的 ASP.NET Core react [C#]
    含 React.js 和 Redux 的 ASP.NET Core reactredux [C#]
    ASP.NET Core Web API webapi [C#],F#
    Razor 类库 razorclasslib [C#]
    global.json 文件 globaljson
    NuGet 配置 nugetconfig
    Web 配置 webconfig
    解决方案文件 sln

    -h|--help
    打印命令帮助。 可针对 dotnet new 命令本身或任何模板(如 dotnet new mvc --help)调用它。
    若要了解如何创建自定义模板,请参阅 dotnet new 自定义模板。
    -l|--list
    列出包含指定名称的模板。 如果针对 dotnet new 命令调用,则它列出可能对给定的目录可用的模板。 例如,如果该目录已包含一个项目,则它不会列出所有项目模板。
    -lang|--language {C#|F#|VB}
    要创建的模板的语言。 接受的语言因模板而异(请参阅参数部分中的默认值)。 对于某些模板无效。
    备注
    某些 shell 将 # 解释为特殊字符。 在这些情况下,需要括住语言参数值,如 dotnet new console -lang "F#"。
    -n|--name <OUTPUT_NAME>
    所创建的输出的名称。 如果未指定名称,使用的是当前目录的名称。
    --nuget-source
    指定在安装期间要使用的 NuGet 源。
    -o|--output <OUTPUT_DIRECTORY>
    用于放置生成的输出的位置。 默认为当前目录。
    --type
    根据可用类型筛选模板。 预定义值为“project”、“item”或“other”。
    -u|--uninstall <PATH|NUGET_ID>
    从提供的 PATH 或 NUGET_ID 卸载源或模板包。
    备注
    若要使用 PATH 卸载模板,需要完全限定路径。 例如,C:/Users//Documents/Templates/GarciaSoftware.ConsoleTemplate.CSharp 有效,但是包含文件夹中的 ./GarciaSoftware.ConsoleTemplate.CSharp 无效。 此外,模板路径中不要包含最后的终止目录斜杠。

    dotnet run - 无需任何显式编译或启动命令即可运行源代码。
    从 .NET Core 2.0 开始,无需运行 dotnet restore,因为它由需有还原的所有命令隐式运行,如 dotnet build 和 dotnet run。 在执行显式还原有意义的某些情况下,例如 Azure DevOps Services 中的持续集成生成中,或在需要显式控制还原发生时间的生成系统中,它仍然是有效的命令。
    以长格式传递命令时,该命令也支持 dotnet restore 选项(例如,--source)。 不支持缩写选项,例如 -s。

  • 相关阅读:
    xp sp3下 IIS5.1 配置python 的正确方法
    asp 采集不到数据,采集不成功 拒绝访问 msxml3.dll 错误 '80070005' 的解决方法
    列表样式
    css文本属性
    css背景属性
    常规流练习
    盒模型练习
    定位体系相关练习
    层叠机制的步骤
    简单网页的制作——html
  • 原文地址:https://www.cnblogs.com/handy1998/p/10061584.html
Copyright © 2011-2022 走看看