Skip to content

dragan/scriptcs

 
 

Repository files navigation

scriptcs

Why should you care?

Write C# apps with a text editor, nuget and the power of Rosyln!

Note: Roslyn is a pre-release CTP and currently an unsupported technology. As such there may be changes in Roslyn itself that could impact this project. Please bear that in mind when using scriptcs

Pre-reqs

  • Install scriptcs from Chocolatey cinst scriptcs or
  • Build the project from the source and put scriptcs.exe in your path.

Quick start

  • Open a cmd prompt as admin
  • run scriptcs -install scriptcs.webapi
  • create a server.csx with your favorite editor. Paste the text below into the file and save (notice no namespaces & no top level class).
public class TestController : ApiController {
  public string Get() {
    return "Hello world!";
  }
}

var webApi = Require<WebApi>();
var server = webApi.CreateServer("http://localhost:8080");
server.OpenAsync().Wait();

Console.WriteLine("Listening...");
Console.ReadKey();
server.CloseAsync().Wait();
  • run scriptcs server.csx

This will launch a web api host with a sample controller, which you can access from the browser.

How it works

scriptcs relies on Roslyn for loading loose C# script files. It will automatically discover nuget packages local to the app and load the binaries.

Docs

Contributing

Credits

  • Special thanks to @filip_woj for being the inspiration behind this with his Roslyn Web API posts.
  • Thanks to the Roslyn team who helped point me in the right direction.

Coordinators

Community

Want to chat? In addition to Twitter, you can find us on Google Groups and JabbR!

License

Apache 2 License

About

Write C# apps with a text editor, nuget and the power of Roslyn!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.5%
  • PowerShell 1.2%
  • Shell 0.3%