These are chat archives for scriptcs/scriptcs

12th
Apr 2016
bejaouibechir
@bejaouibechir
Apr 12 2016 11:09
Hi guys I just discovering scriptcs modules, I followed the tuto https://github.com/scriptcs/scriptcs/wiki/Modules by letter and I suppose at the execution time when loading my module to display Hello World as it is discribed in the tuto the build is ok 0 errors but nothing happens am I missing a detail thank you
Glenn Block
@glennblock
Apr 12 2016 12:51
Hi there
So you installed the module with -g?0
And then ran scriptcs specifying the module in the command line?
Can you tell me exactly what you did @bejaouibechir?
bejaouibechir
@bejaouibechir
Apr 12 2016 18:19
@glennblock thank you for responding me, ok what I did is
floolwing those steps to author my first module
  1. Create a new .NET 4.5 class library. Name it with the template ScriptCs.[ModuleName]Module i.e. ScriptCs.MyModule
  2. Add scriptcs package ScriptCs.Contracts package.
    Add additional packages
    3.Create a new class for the module. Name it with the template [ModuleName]Module.
    4.Implement the IModule interface.
    [Module("helloworld", Extensions = "csx")]
    public class HelloWorldModule : IModule
    {
    public void Initialize(IModuleConfiguration config)
    {
     Console.WriteLine("Hello World");
    }
    }
5.I copied then the generated dll in a folder
6.I navigated to that folder with the command line and executed scriptcs -modules helloworld
I suppose that when scriptcs start executing it will print first Hello World as expected
Glenn Block
@glennblock
Apr 12 2016 18:21
You can't just copy it to to a folder
You have to install it as a package using -g
so you create a nuget package, then you can add it to your pacakge sources on the machine
or you can add a nuget.config in the same folder where you are running.
or maybe its scriptcs_nuget.config now
you need to install it into the global location for it to load as a module
bejaouibechir
@bejaouibechir
Apr 12 2016 18:23
OK if I try to undertand suppose I have developed the dll related to the module
and copied it to let's say c:\test
Glenn Block
@glennblock
Apr 12 2016 18:24
yeah that won't work
bejaouibechir
@bejaouibechir
Apr 12 2016 18:24
I have to navigate to c:\test and run
Glenn Block
@glennblock
Apr 12 2016 18:24
you have to install the module
bejaouibechir
@bejaouibechir
Apr 12 2016 18:24
scriptcs helloworld.dll -g
Glenn Block
@glennblock
Apr 12 2016 18:24
no
:-)
We have a sample module actually on github
bejaouibechir
@bejaouibechir
Apr 12 2016 18:25
ok bear with me I'm just doing my first steps
Glenn Block
@glennblock
Apr 12 2016 18:25
you could try
I don't know if I pushed it to Nuget
bejaouibechir
@bejaouibechir
Apr 12 2016 18:25
could you give me step by step what I sould do once the dll is generated
I'm just test it locally
Glenn Block
@glennblock
Apr 12 2016 18:26
Follow this
it has instructions
I'll add a link to it in that wiki page
bejaouibechir
@bejaouibechir
Apr 12 2016 18:29
Thank you for the link, I think this is more clear than that
https://github.com/scriptcs/scriptcs/wiki/Modules
Glenn Block
@glennblock
Apr 12 2016 18:29
I wrote both :-)
The wiki is more about explaining WHAT modules are
which the sample module does not explain
bejaouibechir
@bejaouibechir
Apr 12 2016 18:30
then you should remove the last one i made me completely lost :)
Glenn Block
@glennblock
Apr 12 2016 18:30
the wiki confused you?
confusedyou how?
Oh the Testing and Debugging
yeah so it used to work
but we had load time issues with searching bin all the time
OK, I'll fix the "Testing and Debugging" section
bejaouibechir
@bejaouibechir
Apr 12 2016 18:30
yes at the point when authorin is at the bottom so I lost the installing part :)
Glenn Block
@glennblock
Apr 12 2016 18:31
Gotcha....yeah originally that flow worked
I'll fix it
I added "Sample Module" now
bejaouibechir
@bejaouibechir
Apr 12 2016 18:32
I think modules are powerfull I will try to toy with them a little if things goe well I like the fact that scriptcs could be exstended
Glenn Block
@glennblock
Apr 12 2016 18:32
they are a double edge sword
they are powerful...but they have some issues to
too
bejaouibechir
@bejaouibechir
Apr 12 2016 18:32
performance
Glenn Block
@glennblock
Apr 12 2016 18:32
not the main problem
bejaouibechir
@bejaouibechir
Apr 12 2016 18:33
security then
Glenn Block
@glennblock
Apr 12 2016 18:33
the main problem is if you have modules and then upgrade scriptcs, sometimes all of scriptcs breaks due to binary compat
we have our own dynamic runtime redirect mechanism that helps mitigate that
but not 10)%
100%
security could be a concern, but they have to be explicitly installed
bejaouibechir
@bejaouibechir
Apr 12 2016 18:34
got it do you know the new AppContext class newly added by the .net 4.6
Glenn Block
@glennblock
Apr 12 2016 18:34
so yeah a malicous module could do bad things
but same with a malicious script pack
bejaouibechir
@bejaouibechir
Apr 12 2016 18:34
this class defines a switch that can change through library versions I tested it and it works well
Glenn Block
@glennblock
Apr 12 2016 18:34
or any malicious package on nuget
so nothing particularly special we bring to the table in terms of risk
bejaouibechir
@bejaouibechir
Apr 12 2016 18:35
The AppContext class can help to avoid versioning
issues
Glenn Block
@glennblock
Apr 12 2016 18:36
Well we are planning to support 4.6 at some point
but right now we are sticking to 4.5 compat
that will start soon
we are going to do a major revamp to support CoreCLR
bejaouibechir
@bejaouibechir
Apr 12 2016 18:36
yeah it will resolve your issue
Glenn Block
@glennblock
Apr 12 2016 18:37
Our dynamic redirect has solved most problems
but happy to get rid of it once we migrate
it is pretty ugly app domain code
though ugly in one eye is elegant in another
bejaouibechir
@bejaouibechir
Apr 12 2016 18:38
I tested the AppContext class with dll versioning wHEN i just change the switch value the client will be redirected toward the target library at the run time
Glenn Block
@glennblock
Apr 12 2016 18:39
nice
bejaouibechir
@bejaouibechir
Apr 12 2016 18:39
It's a cool feature I tried it for dll versions test
Glenn Block
@glennblock
Apr 12 2016 18:39
that's pretty much what we do, though I am sure what they have is much nicer
ours is hacky
but works for our needs
bejaouibechir
@bejaouibechir
Apr 12 2016 18:39
absolutely
Glenn Block
@glennblock
Apr 12 2016 18:39
we did it because we had to
I wrote that code...not super proud of it, but it worked
we had script packs breaking all the time
and it stopped that
bejaouibechir
@bejaouibechir
Apr 12 2016 18:41
I'm not new to C# I'm since 2007 doing staff with C#
http://www.c-sharpcorner.com/members/bechir-bejaoui2
heowever I'm discovering the scriptcs world just last year a lillte and then now
and I remember I got stuck at that level the module :)
I published my first scriptcs pack last year
Glenn Block
@glennblock
Apr 12 2016 18:42
Awesome!
Are you developing on Windows, Linux or Mac?
bejaouibechir
@bejaouibechir
Apr 12 2016 18:43
Both Windows and Linux
and I'm interesting on wirting some staff that gather both envs
And the reason why I'm intersting on scriptcs is that I found it more conftable for me when automating some network staff on Windows server box
Powershell does the job but scriptcs let me profit of the .Net framework
Glenn Block
@glennblock
Apr 12 2016 18:48
Updated the section on testing and debugging
Did you see the new upgrade 0.16.0?
We added a lot of good stuff
newer Roslyn bits with C# 6
and VS debugging
I hear you on the Powershell side. scriptcs is not a replacement for Powershell, but there are a ton of things it can do that without it you'd have to use Powershell
and like you said, you can easily leverage your . NET experience / libs
bejaouibechir
@bejaouibechir
Apr 12 2016 19:17
yes
Glenn Block
@glennblock
Apr 12 2016 20:18
I hope we can get debugging working in VSCode.....
that would be really nice
and in ATOM