2

I'm using Visual Studio 2015 Update 2. According to csi.exe there are such things as 'C# script files':

Executes script-file.csx if specified

Is there are documentation for this format? How can I create them in Visual Studio?


> csi.exe /?

Microsoft (R) Visual C# Interactive Compiler version 1.2.0.60317
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: csi [option] ... [script-file.csx] [script-argument] ...

Executes script-file.csx if specified, otherwise launches an interactive REPL (Read Eval Print Loop).

Options:
  /help                          Display this usage message (alternative form: /?)
  /i                             Drop to REPL after executing the specified script.
  /r:<file>                      Reference metadata from the specified assembly file (alternative form: /reference)
  /r:<file list>                 Reference metadata from the specified assembly files (alternative form: /reference)
  /lib:<path list>               List of directories where to look for libraries specified by #r directive. 
                                 (alternative forms: /libPath /libPaths)
  /u:<namespace>                 Define global namespace using (alternative forms: /using, /usings, /import, /imports)
  @<file>                        Read response file for more options
  --                             Indicates that the remaining arguments should not be treated as options.
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
  • I found this blog post from 2011 https://blogs.msdn.microsoft.com/visualstudio/2011/10/19/introducing-the-microsoft-roslyn-ctp/ but the instructions don't work in Visual Studio 2015 ('Visual C# script' is missing from 'new file') – Colonel Panic Apr 26 '16 at 13:40
  • https://msdn.microsoft.com/en-gb/magazine/mt614271.aspx – Alex K. Apr 26 '16 at 13:42
  • 1
    If it's just a text file surely you don't need a template for it to create it? You can rename files you know – Matti Virkkunen Apr 26 '16 at 13:48

2 Answers2

5

I was able to create a C# Script (.csx) file in Visual Studio 2015 Update 2 by creating a text file from within the IDE and saving it with a .csx extension. I was then able to execute C# code in the C# Script file in C# Interactive (csi.exe) by right clicking and selecting Execute in Interactive. It did run, however there was no intellisense support.

just-joel
  • 61
  • 4
4

Frustratingly, it's not possible. Bug reported to Microsoft. Please add your vote. https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/7848117-add-scriptcs-csx-intellisense-and-debugging-in-v

Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
  • Yes, they close all suggestions related to that like this one https://developercommunity.visualstudio.com/t/No-C-Script-item-in-Create-new-item/1389871 – Andrii Jul 16 '22 at 13:40