Scripts in files

To run hello.xsh just

xsharper hello.xsh

Same, but disable output to info stream:

xsharper hello.xsh //quiet

Same as above, but also copy script output to a file (it will be still displayed in the console)

xsharper hello.xsh //log x.txt

Require script elevation if the current user is not an administrator:

xsharper hello.xsh //requireAdmin

Run code from a URL (signature validation is forced)
To run hello.xsh just

xsharper hello.xsh

Same, but disable output to info stream:

xsharper hello.xsh //quiet

Same as above, but also copy script output to a file (it will be still displayed in the console)

xsharper hello.xsh //log x.txt

Require script elevation if the current user is not an administrator:

xsharper hello.xsh //requireAdmin

Run code from a URL (signature validation is forced)

xsharper http://xsharper.com/lib/hash.xsh

Same, but using a shorter syntax

xsharper #/hash.xsh 

Register XSharper as default handler of .xsh files

xsharper #/register

Configuration files

.NET programs are crazy about configuration files. Many popular frameworks put lots and lots of program data, and even program logic into XML configuration files. While I'm not a big fan of replacement of code verified during compile time with code verified only on runtime, and System.Configuration namespace is a huge beast that takes hundreds of milliseconds to load even on a decent machine, the configuration files do have their legitimate uses.

A big problem with scripting languages is that configuration files are usually loaded by .NET looking at the executable name and location. Not a problem for compiled XSharper scripts. For interpreted scripts, however, the executable is always xsharper.exe and .NET will expect to find its .config file in the binary directory, not where your script is located.

To solve this problem for interpreted scripts, XSharper allows to explicitly specify what configuration file should be used via //config parameter:

C:\>xsharper myscript.xsh //config script-app.config

To make the config madness complete, the script itself may reside in the configuration file (template may be produced via //genconfig):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="xsharper" type="XSharper.Core.ScriptSectionHandler,XSharper.Core" />
  </configSections>
  <!--  Connection strings  -->
  <connectionStrings>
    <add name="mydb" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=mydb;Integrated Security=True;" />
  </connectionStrings>
  <!-- ** XSharper script ** -->
  <xsharper engineVersion="0.9.1057.0" id="WAIT" xmlns="http://www.xsharper.com/schemas/1.0">
    <print>Hello!</print>
  </xsharper>
</configuration>

This can be executed by providing . (dot) as script name:

C:\>xsharper . //config my.config 
Hello!