首页 > 编程语言 >Code-server写个C#

Code-server写个C#

时间:2024-09-17 23:03:14浏览次数:5  
标签:Code ms C# HelloWorld server https dotnet aka

安装.NET SDK

sudo apt update
sudo apt install wget
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt install dotnet-sdk-6.0

创建C#项目

code-server 中创建一个新的 C# 控制台应用程序:
code-server 中打开终端 (Ctrl+Shift+t 或者 Terminal > New Terminal)。
使用 cd 命令切换到你希望存放项目的目录。
使用 dotnet new console 命令创建一个新的控制台应用程序HelloWorld:

$ sudo dotnet new console -n HelloWorld

Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.425

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/coder/scripts/HelloWorld/HelloWorld.csproj...
  Determining projects to restore...
  Restored /home/coder/scripts/HelloWorld/HelloWorld.csproj (in 90 ms).
Restore succeeded.

编辑程序内容

然后进入HelloWorld路径
再在code-server中打开该文件夹,并编辑Program.cs文件,输入以下内容:

// See https://aka.ms/new-console-template for more information
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World! C# in code-server!");
        }
    }
}

文件权限

此时,可能遇到保存权限的问题。

 sudo chown -R coder:coder /home/coder/scripts/

编译

~/scripts/HelloWorld$ dotnet build
MSBuild version 17.3.4+a400405ba for .NET
  Determining projects to restore...
  Restored /home/coder/scripts/HelloWorld/HelloWorld.csproj (in 119 ms).
  HelloWorld -> /home/coder/scripts/HelloWorld/bin/Debug/net6.0/HelloWorld.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.23

运行

$ dotnet run
Hello, World! C# in code-server!

可以看到在terminal打印出HelloWorld。程序运行成功。

标签:Code,ms,C#,HelloWorld,server,https,dotnet,aka
From: https://www.cnblogs.com/PrepAndPonder/p/18417690

相关文章

  • 代码随想录Day3 | LeetCode 203. 移除链表元素、LeetCode 707. 设计链表、LeetCode 20
    LeetCode203.移除链表元素链表基础概念题,也可以用递归做,不过我们把递归的思想放在更能体现它的LeetCode206.反转链表#Definitionforsingly-linkedlist.#classListNode:#def__init__(self,val=0,next=None):#self.val=val#self.next......
  • 代码随想录Day4 | LeetCode 24. 两两交换链表中的节点、LeetCode 19. 删除链表的倒数
    LeetCode24.两两交换链表中的节点递归思想#Definitionforsingly-linkedlist.#classListNode:#def__init__(self,val=0,next=None):#self.val=val#self.next=nextclassSolution:defswapPairs(self,head:Optional[ListNode......
  • windows系统Tomcat启动过程中找不到JAVA_HOME nor the JRE_HOME解决方法
    有很多人第一次下载Tomcat时会遇到一个问题,就是信心满满按着教程配置好环境之后,一运行startup.bat会出现一下问题:NeithertheJAVA_HOMEnortheJRE_HOMEenvironmentvariableisdefinedAtleastoneoftheseenvironmentvariableisneededtorunthisprogram;在......
  • 蓝桥杯【物联网】零基础到国奖之路:八. RTC
    蓝桥杯【物联网】零基础到国奖之路:八.RTC第一节RTC的基本知识第二节CubeMX配置第三节代码第一节RTC的基本知识RTC是实时时钟,指可以想时钟一样输出实际时间的电子设备,一般会是集成电路,也被称为是时钟芯片。总之,RTC只是一个靠电池维持运行的32位定时器,并不像实时......
  • 手车投屏一:ICCOA
    ICCOACarlink实现手机桌面投屏到车机屏幕的底层原理主要涉及无线通信技术、屏幕共享技术和用户交互技术的综合运用。以下是对其底层原理的详细阐述:1.无线通信技术ICCOACarlink支持无线连接,这主要通过Wi-Fi、蓝牙等无线通信技术实现。在首次连接时,手机和车机需要通过这......
  • 手车互联二:scrcpy
    在Android系统中,使用ADB(AndroidDebugBridge)命令来启动特定应用于指定的displayId上,以及使用scrcpy这样的工具来屏幕镜像或控制特定显示设备的操作,都涉及到了Android的多显示支持(Multi-Display)技术。下面将分别展开描述这两种操作的技术原理。使用ADB启动应用于指定Displa......
  • hMail Server更改DB为MySQL
    hMail默认DB是MSSQLServerCompact3.5根据业务需要修改为MySQL1.-下载安装MySQL:https://dev.mysql.com/downloads/mysql/需要先安装VSC++Redistributable:https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-......
  • 【CMake】使用CMake在Visual Stdudio中配置glad和glfw
    下载glad和glfwgladgladglad下载:glad下载这个是......
  • C#实现扫码枪串口通信(利用serialPort控件重写)
     1usingSystem;2usingSystem.Collections.Generic;3usingSystem.ComponentModel;4usingSystem.Data;5usingSystem.Drawing;6usingSystem.IO.Ports;7usingSystem.Linq;8usingSystem.Text;9usingSystem.Threading.Tasks;10usi......
  • 【网络安全 | PHP代码审计】熊海cms
    原创文章,禁止转载。文章目录环境搭建代码审计文件包含漏洞SQL注入漏洞1SQL注入漏洞2SQL注入漏洞3SQL注入漏洞4SQL注入漏洞5SQL注入漏洞6XSS漏洞1XSS漏洞2垂直越权CSRF1CSRF2逻辑漏洞环境搭建https://down.chinaz.com/soft/36930.htm解......