[![stand with Ukraine](https://img.shields.io/badge/stand_with-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)
# CS-Script
<img align="right" src="https://raw.githubusercontent.com/oleg-shilo/cs-script/master/src/logo/css_logo_100x100.png" alt="" style="float:right">
---
This page is a one-minute-read info about the brightest features of the system. The complete overview can be found on [Wiki](https://github.com/oleg-shilo/cs-script/wiki/CS-Script-Overview)
---
_Please note that this repository is hosting the releases of CS-Script (v4.0.0 and higher). Previous content of this repository and wiki (.NET Framework edition of CS-Script) has been been moved to the new repository: https://github.com/oleg-shilo/cs-script.net-framework_
_Note .NET SDK is required to have all features. However the core features can utilized even with .NET Runtime only. See [details](https://github.com/oleg-shilo/cs-script/wiki/Choosing-Compiler-Engine#compiler-technology-comparison)._
---
[![CI](https://github.com/oleg-shilo/cs-script/actions/workflows/dotnet-desktop.yml/badge.svg)](https://github.com/oleg-shilo/cs-script/actions/workflows/dotnet-desktop.yml)
[![Build status](https://ci.appveyor.com/api/projects/status/github/oleg-shilo/cs-script?svg=true)](https://ci.appveyor.com/project/oleg-shilo/cs-script) [![Chocolatey Version](http://img.shields.io/chocolatey/v/cs-script.svg?style=flat-square)](http://chocolatey.org/packages/cs-script) [![Chocolatey Downloads](http://img.shields.io/chocolatey/dt/cs-script.svg?style=flat-square)](http://chocolatey.org/packages/cs-script) [![NuGet version (CS-Script)](https://img.shields.io/nuget/v/CS-Script.svg?style=flat-square)](https://www.nuget.org/packages/CS-Script/)
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://oleg-shilo.github.io/cs-script/Donation.html)
CS-Script is a CLR-based scripting system that uses ECMA-compliant C# as a programming language.
CS-Script is one of the most mature C# scripting solutions. It became publicly available in 2004, just two years after the first release of .NET. And it was the first comprehensive scripting platform for .NET
CS-Script supports both hosted and standalone (CLI) execution models. This makes it possible to use the script engine as a pure C# alternative for PowerShell. As well as extending .NET applications with C# scripts executed at runtime by the hosted script engine.
CS-Script allows seamlessly switching underlying compiling technology without affecting the code base. Currently supported compilers are _dotnet.exe_ and _csc.exe_.
CS-Script also offers comprehensive integration with the most common development tools:
- Visual Studio (built-in feature via `-vs` CLI argument)
- [VSCode](https://github.com/oleg-shilo/cs-script.vscode)
- [Sublime Text 3](https://github.com/oleg-shilo/cs-script-sublime)
- _Legacy .NET Framework plugins that are yet to be ported to .NET 5:_
- [Notepad++](https://github.com/oleg-shilo/cs-script.npp) .
- [Visual Studio](https://github.com/oleg-shilo/CS-Script.VSIX)
It can be run on Win and Linux. Class library for hosting the script engine is compiled for ".NET Standard" so it can be hosted by any managed application.
Over the long history of CS-Script it has been downloaded through Notepad++ x86 plugin manager alone over ![](https://oleg-shilo.github.io/cs-script/download.stats/css.npp.count.jpeg) times ([stats](https://www.cs-script.net/cs-script/download.stats/daily_downloads.html) till July 2017).
<hr/>
_**Documentation disclaimer**_
Please be aware that the online [Documentation Wiki](https://github.com/oleg-shilo/cs-script/wiki) is intended to provide the most detailed information about the product. It is constantly evolving and sometimes may have be a little out of sync concerning the latest product releases.
Though, the most accurate and concise documentation is embedded in the engine executable and can be accessed via CLI "help" command:
```ps
css -help
```
A copy of the help content can be accessed [here](help.txt)
#### _**Howto get CS-Script**_
Note, every [release](https://github.com/oleg-shilo/cs-script/releases) comes with a detailed description of how to deploy/integrate CS-Script on/with your environment or application. This covers various package distribution solutions
- .NET Tools
- Chocolatey
- WinGet
- Debian package
- NuGet package
<hr/>
The following section describes a few use cases just to give you an idea about the product:
_**CLI: Executing script from shell**_
CS-Script follows many elements of the Python user experience model. Thus a script can reference other scripts, .NET assemblies or even NuGet packages. It also uses Python style caching ensuring that script that was executed at least once is never compiled again unless the script code is changes. This ensures ultimate performance. Thus script execution speed of the consecutive runs matches the excution of fully compiled .NET applications.
Create a simple console script:
_You can script any type of application that .NET supports (e.g. WinForm, WPF, WEB API) and in two supported syntaxes: C# and VB._
```ps
cscs -new script.cs
```
This creates a sample script file with a sample code. Of course you can also create the script file by yourself. This is a top-level class script:
```C#
using System;
Console.WriteLine(user());
string user()
=> Environment.UserName;
```
Execute script file directly in cmd-prompt/linux-shell without building an executable assembly:
```
css .\script.cs
```
Note, while the script engine CLI executables is `cscs.exe` (on Win) and `cscs` (on Linux) you can use `css` shim that is available in both win and linux distro.
_**CLI: Executing script from IDE**_
While various IDEs can be used VSCode is arguably the simplest one.
You can either load the existing script into it with `css -vscode .\script.cs` or create a new script within the IDE if you install the [CS-Script extension](https://marketplace.visualstudio.com/items?itemName=oleg-shilo.cs-script):
![](https://user-images.githubusercontent.com/16729806/108838856-53b3e500-7628-11eb-8979-9b464484afec.gif)
_**Hosting script engine**_
You can host the script engine in any .NET application. The class library is distributed as a NuGet package [CS-Script](https://www.nuget.org/packages/CS-Script/).
```ps
Install-Package CS-Script
```
The library is built against _.NET Standard 2.0_ so it can be hosted on any edition of runtime. However the script evaluation is done via .NET 5 tool chain so it needs to be installed on the host PC even if the application is implemented with the older framework (e.g. .NET Framework).
These are just a few samples:
_The complete content of samples can be found [here](https://github.com/oleg-shilo/cs-script.core/blob/master/src/CSScriptLib/src/CSScriptLib/samples.cs)._
```C#
public interface ICalc
{
int Sum(int a, int b);
}
...
// you can but don't have to inherit your script class from ICalc
ICalc calc = CSScript.Evaluator
.LoadCode<ICalc>(@"using System;
public class Script
{
public int Sum(int a, int b)
{
return a+b;
}
}");
int result = calc.Sum(1, 2);
```
```C#
dynamic script = CSScript.Evaluator
.LoadMethod(@"int Product(int a, int b)
{
return a * b;
}");
int result = script.Product(3, 2);
```
```C#
public interface ICalc
{
int Sum(int a, int b);
int Div(int a, int b);
}
...
ICalc script = CSScript.Evaluator
.LoadMethod<ICalc>(@"public int Sum(int a, int b)
没有合适的资源?快使用搜索试试~ 我知道了~
C# scripting platform.zip
共931个文件
htm:230个
cs:149个
html:123个
需积分: 5 0 下载量 122 浏览量
2023-12-31
10:04:36
上传
评论
收藏 10.61MB ZIP 举报
温馨提示
C# scripting platform.zip
资源推荐
资源详情
资源评论
收起资源包目录
C# scripting platform.zip (931个子文件)
Welcome.aml 1KB
VersionHistory.aml 974B
v1.0.0.0.aml 713B
Hello.asmx 76B
search.bmp 1014B
synch.bmp 822B
changelog 167B
1.build-binaries.cmd 5KB
3.build-documentation.cmd 870B
1.build-release.cmd 231B
2.run-tests-ci.cmd 166B
2.run-tests.cmd 162B
publish.cmd 158B
3.build-linux-distro.cmd 149B
build.cmd 147B
publish.cmd 32B
build.cmd 22B
build.cmd 13B
compat 2B
packages.config 1KB
App.config 1KB
web.config 234B
App.config 184B
App.config 175B
CustomAppSettings.cs.config 151B
CustomAppSettings.cs.config 146B
ContentLayout.content 730B
control 541B
control 489B
control 484B
copyright 1KB
HelpProvider.cs 120KB
csscript.cs 104KB
Utils.cs 81KB
csparser.cs 55KB
csparser.cs 52KB
EvaluatorBase.cs 49KB
IEvaluator.cs 43KB
Settings.cs 38KB
Evaluator.Roslyn.cs 36KB
NuGet.Core.cs 29KB
Evaluator.Api.Test.cs 26KB
CSharpCompiler.engines.cs 25KB
dbg-runtime.cs 24KB
ScriptParser.cs 22KB
Evaluator.CodeDom.cs 22KB
Proxies.cs 21KB
CSScript.cs 19KB
dbg-inject.cs 19KB
CoreExtensions.cs 18KB
Precompiler.cs 18KB
fileparser.cs 17KB
BuildServer.cs 17KB
Evaluator.Roslyn.Tests.cs 17KB
cli.cs 17KB
Services.Roslyn.cs 16KB
Runtime.cs 14KB
Globals.cs 13KB
ReflectionExtensions.cs 13KB
css_update.cs 13KB
AssemblyResolver.cs 12KB
compilers.cs 12KB
AssemblyExecutor.cs 11KB
PathExtensions.cs 11KB
ExecuteOptions.cs 11KB
Evaluator.CodeDom.Test.cs 10KB
cmd.cs 10KB
dbg.res.cs 10KB
csscript.cli.cs 10KB
cmd.cs 10KB
samples.cs 9KB
dbg.cs 9KB
CorFlagsReader.cs 9KB
DebuggingService.cs 9KB
CSExecutionClient.cs 9KB
StringExtensions.cs 8KB
Project.cs 8KB
ConsoleExtensions.cs 7KB
-run.cs 7KB
AssemblyResolver.cs 7KB
SimpleAsmProbing.cs 6KB
Program.cs 6KB
FileParserTests.cs 6KB
who.cs 6KB
CompilerError.cs 6KB
Exceptions.cs 5KB
css.cs 5KB
xunit.polyfill.cs 5KB
CoreExtension.Local.cs 4KB
synTime.cs 4KB
synTime.cs 4KB
VSConfig.cs 4KB
Program.cs 4KB
CLIExtensions.cs 4KB
LinqExtensions.cs 4KB
css.cs 4KB
CompilerResults.cs 4KB
Program.cs 4KB
WildCardExtensions.cs 4KB
Program.cs 4KB
共 931 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
暮苍梧~
- 粉丝: 41
- 资源: 258
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python39.dll
- 【Matlab 六自由度机器人】Fixed Angles(固定角度) 和 Euler Angles(欧拉角) 之间的区别
- BMSP430工程PPT说明书.zip
- FlinkFlinkF
- 《计算机网络-自顶向下方法》答案
- 基于pyqt5框架开发的demo项目 全栈开发,短小精悍,入门学习,上手简单
- 国内IP地址大全 站长资源 访问IP设置 Order allow,deny 使用方法
- 【JavaScript实现点击鼠标出现爱心特效脚本】直接引入index.html文件可用!!!
- OPC Core Components Redistributable (x86).msi
- 一套基于Python的交易量化框架,详细复现步骤
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功