美文网首页
c#直接运行cs单文件 /运行脚本

c#直接运行cs单文件 /运行脚本

作者: 吉凶以情迁 | 来源:发表于2024-07-30 15:51 被阅读0次

dotnet tool install -g dotnet-script
dotnet script script.cs

#if DEBUG ||RELEASE

#else
#define SCRIPT
#endif

using System;

using System.IO;
using System.Diagnostics;
using System.Text;

public class ProgramScript
{
    //dotnet tool install -g dotnet-script
    public static void Main(string[] args)
    {
        String a = "";
#if DEBUG
        Console.WriteLine("Debug mode");
#endif
#if TRACE
            Console.WriteLine("Tracing is enabled");
#endif
#if WINDOWS
            Console.WriteLine("Running on Windows");
#elif LINUX
            Console.WriteLine("Running on Linux");
#elif OSX
            Console.WriteLine("Running on macOS");
##else
            Console.WriteLine("Unknown Platform");
#endif
#if NETCOREAPP
        Console.WriteLine("Running on .NET Core or .NET 5+");
#elif NETFRAMEWORK
            Console.WriteLine("Running on .NET Framework");
#else
            Console.WriteLine("Running on Script");
#endif
        string projectName = "WEBAPI";
        string currentDirectory = Directory.GetCurrentDirectory();
        string channelName = Environment.GetEnvironmentVariable("CHNAMENAME");
        string platform = Environment.GetEnvironmentVariable("PLATFORM");
        string companyName = Environment.GetEnvironmentVariable("COMPANYNAME");
        string COREVERSION = Environment.GetEnvironmentVariable("COREVERSION");
     //省略1万字
        Console.WriteLine("结束");
    }



 
}
#if SCRIPT
ProgramScript.Main( new String[] { });
#else

#endif

相关文章

  • vscode插件

    code runner 可以直接运行脚本文件Code Runner

  • bash编程-Shell基础

    1. Shell脚本执行方式 直接运行,需要在脚本文件头部指定解释器,如#!/bin/bash 运行时指定shel...

  • C#程序的编译运行过程

    编译运行过程图 过程 首先将C#源文件hello.cs通过编译器进行编译,编译成.NET的PE文件结构,即exe文...

  • opensuse下pptpd一键安装脚本

    原始出处 将上述脚本保存为文件pptpd.sh运行脚本前为pptpd.sh文件赋予运行权限 运行脚本 有些版本pp...

  • 递归查找文件夹下的空文件夹

    递归查找指定文件夹下的空文件夹 此脚本有两种用法脚本放在需要查找的文件夹下,直接运行(提示输入直接跳过)脚本放在任...

  • 【XLua】015-Lua访问C#:静态属性,方法

    访问C#静态属性,方法 1、Lua脚本: 2、C#脚本: 运行结果: 小技巧: 如果需要经常访问的类,可以先用局部...

  • 使用ansible-playbook-案例4

    脚本文件如下 运行一个playbook playbook中包含安装基础软件包 拷贝脚本文件 运行脚本文件 检查pl...

  • homebrew 安装

    运行脚本 https://brew.sh 或者直接运行下面脚本可以选择国内镜像

  • Stata v.s. Python双剑合并

    在stata中调用python 运行python代码 直接运行整个python脚本

  • 第一章 小试牛刀

    shell 脚本通常是以 #! 起始的文本文件。有两种运行脚本文件的方式: 将脚本作为sh 命令行参数运行 将脚本...

网友评论

      本文标题:c#直接运行cs单文件 /运行脚本

      本文链接:https://www.haomeiwen.com/subject/mgyshjtx.html