实例介绍
dotnet script
从.NET CLI运行C#脚本,内联定义NuGet包,并在VS Code中编辑/调试它们,而且还能获得来自OmniSharp的完整语言服务支持。
.NET Core全局工具
.NET Core 2.1引入了全局工具的概念,这意味着你可以使用.NET CLI安装dotnet-script。
dotnet tool install -g dotnet-script
【实例截图】

【核心代码】
文件清单
└── dotnet-script-be499540b8895dbc2902771e3fdb259d97235adc
├── build
│ ├── BuildContext.csx
│ ├── Build.csx
│ ├── Dockerfile
│ ├── install-dotnet-script.ps1
│ ├── install-dotnet-script.sh
│ ├── omnisharp.json
│ └── prerestore.Dockerfile
├── build.ps1
├── build.sh
├── Dotnet.Script.sln
├── global.json
├── install
│ ├── install.ps1
│ └── install.sh
├── LICENSE
├── NuGet.Config
├── omnisharp.json
├── README.md
└── src
├── Dotnet.Script
│ ├── dotnet-script.cmd
│ ├── Dotnet.Script.csproj
│ ├── dotnet-script.sh
│ ├── Extensions.cs
│ ├── LogHelper.cs
│ ├── Program.cs
│ └── Properties
│ └── AssemblyInfo.cs
├── Dotnet.Script.Core
│ ├── Commands
│ │ ├── ExecuteCodeCommand.cs
│ │ ├── ExecuteCodeCommandOptions.cs
│ │ ├── ExecuteInteractiveCommand.cs
│ │ ├── ExecuteInteractiveCommandOptions.cs
│ │ ├── ExecuteLibraryCommand.cs
│ │ ├── ExecuteLibraryCommandOptions.cs
│ │ ├── ExecuteScriptCommand.cs
│ │ ├── ExecuteScriptCommandOptions.cs
│ │ ├── InitCommand.cs
│ │ ├── InitCommandOptions.cs
│ │ ├── PublishCommand.cs
│ │ └── PublishCommandOptions.cs
│ ├── CSharpObjectFormatterExtensions.cs
│ ├── Dotnet.Script.Core.csproj
│ ├── Extensions.cs
│ ├── Interactive
│ │ ├── ClsCommand.cs
│ │ ├── CommandContext.cs
│ │ ├── ExitCommand.cs
│ │ ├── IInteractiveCommand.cs
│ │ ├── InteractiveCommandProvider.cs
│ │ ├── InteractiveRunner.cs
│ │ └── ResetInteractiveCommand.cs
│ ├── Internal
│ │ ├── EnumerableExtensions.cs
│ │ ├── PreprocessorLineRewriter.cs
│ │ ├── ScriptExtensions.cs
│ │ └── StringExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Scaffolder.cs
│ ├── ScriptAssemblyLoadContext.cs
│ ├── ScriptCompilationContext.cs
│ ├── ScriptCompiler.cs
│ ├── ScriptConsole.cs
│ ├── ScriptContext.cs
│ ├── ScriptDownloader.cs
│ ├── ScriptEmitResult.cs
│ ├── ScriptEmitter.cs
│ ├── ScriptFile.cs
│ ├── ScriptLogger.cs
│ ├── ScriptPublisher.cs
│ ├── ScriptRunner.cs
│ ├── ScriptRuntimeException.cs
│ ├── Templates
│ │ ├── globaltool.launch.json.template
│ │ ├── helloworld.csx.template
│ │ ├── launch.json.template
│ │ ├── omnisharp.json.template
│ │ ├── program.publish.template
│ │ └── TemplateLoader.cs
│ └── Versioning
│ ├── EnvironmentReporter.cs
│ ├── IVersionProvider.cs
│ ├── LoggedVersionProvider.cs
│ ├── VersionInfo.cs
│ └── VersionProvider.cs
├── Dotnet.Script.DependencyModel
│ ├── AssemblyProperties.cs
│ ├── Compilation
│ │ ├── CompilationDependency.cs
│ │ ├── CompilationDependencyResolver.cs
│ │ ├── CompilationReference.cs
│ │ ├── CompilationReferencesReader.cs
│ │ └── ICompilationReferenceReader.cs
│ ├── Context
│ │ ├── CachedRestorer.cs
│ │ ├── DotnetRestorer.cs
│ │ ├── IRestorer.cs
│ │ ├── ProfiledRestorer.cs
│ │ ├── ScriptDependencyContext.cs
│ │ ├── ScriptDependencyContextReader.cs
│ │ ├── ScriptDependency.cs
│ │ └── ScriptMode.cs
│ ├── Dotnet.Script.DependencyModel.csproj
│ ├── Environment
│ │ └── ScriptEnvironment.cs
│ ├── Internal
│ │ └── CommandLine.cs
│ ├── Logging
│ │ └── LogActionExtensions.cs
│ ├── Process
│ │ └── CommandRunner.cs
│ ├── ProjectSystem
│ │ ├── AssemblyReference.cs
│ │ ├── csproj.template
│ │ ├── FileUtils.cs
│ │ ├── NuGetUtilities.cs
│ │ ├── PackageId.cs
│ │ ├── PackageReference.cs
│ │ ├── PackageVersion.cs
│ │ ├── ParseResult.cs
│ │ ├── ProjectFile.cs
│ │ ├── ProjectFileInfo.cs
│ │ ├── ScriptFilesResolver.cs
│ │ ├── ScriptParser.cs
│ │ ├── ScriptParserInternal.cs
│ │ └── ScriptProjectProvider.cs
│ ├── Runtime
│ │ ├── RuntimeAssembly.cs
│ │ ├── RuntimeDependency.cs
│ │ └── RuntimeDependencyResolver.cs
│ └── ScriptPackage
│ └── ScriptFilesDependencyResolver.cs
├── Dotnet.Script.DependencyModel.Nuget
│ ├── Dotnet.Script.DependencyModel.NuGet.csproj
│ ├── NuGetMetadataReferenceResolver.cs
│ └── NuGetSourceReferenceResolver.cs
├── Dotnet.Script.Desktop.Tests
│ ├── CompilationDepenencyTests.cs
│ ├── Dotnet.Script.Desktop.Tests.csproj
│ ├── InteractiveRunnerTests.cs
│ └── xunit.runner.json
├── Dotnet.Script.Extras
│ ├── Dotnet.Script.Extras.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── RemoteFileResolver.cs
├── Dotnet.Script.Shared.Tests
│ ├── Dotnet.Script.Shared.Tests.csproj
│ ├── FileUtils.cs
│ ├── InteractiveRunnerTestsBase.cs
│ ├── ProcessHelper.cs
│ ├── ProcessResult.cs
│ ├── TestOutputHelper.cs
│ └── TestPathUtils.cs
├── dotnet-script.snk
├── Dotnet.Script.Tests
│ ├── CachedRestorerTests.cs
│ ├── Commands
│ │ └── ExecuteInteractiveCommandTests.cs
│ ├── CompilationDependencyResolverTests.cs
│ ├── DisposableFolder.cs
│ ├── DotnetRestorerTests.cs
│ ├── Dotnet.Script.Tests.csproj
│ ├── EnvironmentTests.cs
│ ├── ExecutionCacheTests.cs
│ ├── FileUtilsTests.cs
│ ├── InteractiveRunnerTests.cs
│ ├── NuGet
│ │ └── NuGet430.exe
│ ├── NuGetSourceReferenceResolverTests.cs
│ ├── OnlyOnUnixFactAttribute.cs
│ ├── PackageSourceTests.cs
│ ├── PackageVersionTests.cs
│ ├── ProjectFileTests.cs
│ ├── ScaffoldingTests.cs
│ ├── ScriptdependencyContextReaderTests.cs
│ ├── ScriptExecutionTests.cs
│ ├── ScriptFilesResolverTests.cs
│ ├── ScriptPackages
│ │ ├── WithAnyTargetFramework
│ │ │ ├── contentFiles
│ │ │ │ └── csx
│ │ │ │ └── any
│ │ │ │ └── main.csx
│ │ │ └── WithAnyTargetFramework.nuspec
│ │ ├── WithMainCsx
│ │ │ ├── contentFiles
│ │ │ │ └── csx
│ │ │ │ └── netstandard2.0
│ │ │ │ └── main.csx
│ │ │ └── WithMainCsx.nuspec
│ │ ├── WithNoEntryPointFile
│ │ │ ├── contentFiles
│ │ │ │ └── csx
│ │ │ │ └── any
│ │ │ │ ├── Bar.csx
│ │ │ │ └── Foo.csx
│ │ │ └── WithNoEntryPointFile.nuspec
│ │ ├── WithScriptPackageDependency
│ │ │ ├── contentFiles
│ │ │ │ └── csx
│ │ │ │ └── netstandard2.0
│ │ │ │ └── main.csx
│ │ │ └── WithScriptPackageDependency.nuspec
│ │ └── WithSubFolder
│ │ ├── contentFiles
│ │ │ └── csx
│ │ │ └── netstandard2.0
│ │ │ ├── Foo.csx
│ │ │ └── SubFolder
│ │ │ └── bar.csx
│ │ └── WithSubFolder.nuspec
│ ├── ScriptPackagesFixture.cs
│ ├── ScriptPackagesTests.cs
│ ├── ScriptParserTests.cs
│ ├── ScriptProjectProviderTests.cs
│ ├── ScriptPublisherTests.cs
│ ├── ScriptRunnerTests.cs
│ ├── ScriptTestRunner.cs
│ ├── TestFixtures
│ │ ├── Arguments
│ │ │ └── Arguments.csx
│ │ ├── CompilationError
│ │ │ └── CompilationError.csx
│ │ ├── CompilationWarning
│ │ │ └── CompilationWarning.csx
│ │ ├── Configuration
│ │ │ └── Configuration.csx
│ │ ├── CSharp72
│ │ │ └── CSharp72.csx
│ │ ├── CSharp80
│ │ │ └── CSharp80.csx
│ │ ├── CurrentContextualReflectionContext
│ │ │ └── CurrentContextualReflectionContext.csx
│ │ ├── EnvironmentExitCode
│ │ │ └── EnvironmentExitCode.csx
│ │ ├── Exception
│ │ │ └── Exception.csx
│ │ ├── HelloWorld
│ │ │ └── HelloWorld.csx
│ │ ├── InlineNugetPackage
│ │ │ └── InlineNugetPackage.csx
│ │ ├── InlineNugetPackageWithFileFiltering
│ │ │ ├── InlineNugetPackage.csx
│ │ │ └── SkippedInlineNugetPackage.csx
│ │ ├── InlineNugetPackageWithRefFolder
│ │ │ └── InlineNugetPackageWithRefFolder.csx
│ │ ├── InvalidGlobalJson
│ │ │ ├── global.json
│ │ │ └── InvalidGlobalJson.csx
│ │ ├── Isolation
│ │ │ └── Isolation.csx
│ │ ├── Issue129
│ │ │ └── Issue129.csx
│ │ ├── Issue166
│ │ │ └── Issue166.csx
│ │ ├── Issue181
│ │ │ └── Issue181.csx
│ │ ├── Issue189
│ │ │ ├── AnotherFolder
│ │ │ │ └── Dependencies.csx
│ │ │ └── SomeFolder
│ │ │ └── Script.csx
│ │ ├── Issue198
│ │ │ └── Issue198.csx
│ │ ├── Issue204
│ │ │ └── Issue204.csx
│ │ ├── Issue214
│ │ │ └── Issue214.csx
│ │ ├── Issue268
│ │ │ └── Issue268.csx
│ │ ├── Issue318
│ │ │ └── Issue318.csx
│ │ ├── Issue435
│ │ │ └── Issue435.csx
│ │ ├── Issue613
│ │ │ └── Issue613.csx
│ │ ├── LocalNuGetConfig
│ │ │ ├── LocalNuGetConfig.csx
│ │ │ └── NuGet.Config
│ │ ├── MicrosoftExtensionsDependencyInjection
│ │ │ └── MicrosoftExtensionsDependencyInjection.csx
│ │ ├── NativeLibrary
│ │ │ └── NativeLibrary.csx
│ │ ├── Nullable
│ │ │ └── Nullable.csx
│ │ ├── NullableDisabled
│ │ │ └── NullableDisabled.csx
│ │ ├── Process
│ │ │ └── Process.csx
│ │ ├── REPL
│ │ │ └── main.csx
│ │ ├── ReturnValue
│ │ │ └── ReturnValue.csx
│ │ ├── ScriptPackage
│ │ │ ├── WithAnyTargetFramework
│ │ │ │ ├── NuGet.Config
│ │ │ │ └── WithAnyTargetFramework.csx
│ │ │ ├── WithInvalidPackageReference
│ │ │ │ ├── NuGet.Config
│ │ │ │ └── WithInvalidPackageReference.csx
│ │ │ ├── WithMainCsx
│ │ │ │ ├── NuGet.Config
│ │ │ │ └── WithMainCsx.csx
│ │ │ ├── WithNoEntryPointFile
│ │ │ │ ├── NuGet.Config
│ │ │ │ └── WithNoEntryPointFile.csx
│ │ │ ├── WithNoNuGetConfig
│ │ │ │ └── WithNoNuGetConfig.csx
│ │ │ ├── WithScriptPackageDependency
│ │ │ │ ├── NuGet.Config
│ │ │ │ └── WithScriptPackageDependency.csx
│ │ │ └── WithSubFolder
│ │ │ ├── NuGet.Config
│ │ │ └── WithSubFolder.csx
│ │ ├── TargetFrameworkInShebang
│ │ │ └── TargetFrameworkInShebang.csx
│ │ ├── UnsupportedSdk
│ │ │ └── UnsupportedSdk.csx
│ │ ├── VersionRange
│ │ │ └── VersionRange.csx
│ │ ├── WebApi
│ │ │ └── WebApi.csx
│ │ └── WebApiNet6
│ │ └── WebApiNet6.csx
│ ├── VersioningTests.cs
│ └── xunit.runner.json
└── omnisharp.json
103 directories, 229 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论