How can I execute irake from C#? static void Main(string[] args) { var engine = IronRuby.Ruby.CreateEngine(); engine.Execute("../../rake foo"); } The above does not work! -- Posted via http://www.ruby-forum.com/.
Try with "call irake" On Thursday, January 14, 2010, Mohammad Azam <lists at ruby-forum.com> wrote:> How can I execute irake from C#? > > ?static void Main(string[] args) > ? ? ? ?{ > ? ? ? ? ? ?var engine = IronRuby.Ruby.CreateEngine(); > ? ? ? ? ? ?engine.Execute("../../rake foo"); > ? ? ? ?} > > The above does not work! > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-- --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero GSM: +32.486.787.582 Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero)
call irake foo did not work! The reason is that in order to run irake it is required that I run dev.bat first which seems weird and silly! -- Posted via http://www.ruby-forum.com/.
a) irake is meant to be a command line runner, if you are trying to execute it from C#, then you should be executing a single file that is a rake application. b) dev.bat is for developing IronRuby. If you don''t like dev.bat, and you just want to use IronRuby, use a release zip, not the git repo. JD -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam Sent: Thursday, January 14, 2010 12:36 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Executing irake from C# call irake foo did not work! The reason is that in order to run irake it is required that I run dev.bat first which seems weird and silly! -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Jim Deville wrote:> a) irake is meant to be a command line runner, if you are trying to > execute it from C#, then you should be executing a single file that is a > rake application. > b) dev.bat is for developing IronRuby. If you don''t like dev.bat, and > you just want to use IronRuby, use a release zip, not the git repo. > > JDwhat do u mean by rake application? -- Posted via http://www.ruby-forum.com/.
http://onestepback.org/index.cgi/Tech/Rake/FindInCode.red -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam Sent: Thursday, January 14, 2010 12:50 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Executing irake from C# Jim Deville wrote:> a) irake is meant to be a command line runner, if you are trying to > execute it from C#, then you should be executing a single file that is > a rake application. > b) dev.bat is for developing IronRuby. If you don''t like dev.bat, and > you just want to use IronRuby, use a release zip, not the git repo. > > JDwhat do u mean by rake application? -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Jim Deville wrote:> http://onestepback.org/index.cgi/Tech/Rake/FindInCode.redI am not sure if the article above is related to my issue. I want to simply execute a rake task using IronRuby engine in DLR. I can do this: static void Main(string[] args) { var engine = IronRuby.Ruby.CreateEngine(); engine.Execute("puts ''hello ironruby''"); } but how can I execute a rake task without using another .rb file. -- Posted via http://www.ruby-forum.com/.
something like this then. require ''rubygems''; require ''rake''; require ''../../Rakefile''; Rake::Task[''mytask''].execute --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero GSM: +32.486.787.582 Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Thu, Jan 14, 2010 at 10:01 PM, Mohammad Azam <lists at ruby-forum.com>wrote:> Jim Deville wrote: > > http://onestepback.org/index.cgi/Tech/Rake/FindInCode.red > > I am not sure if the article above is related to my issue. > > I want to simply execute a rake task using IronRuby engine in DLR. > > I can do this: > > static void Main(string[] args) > { > var engine = IronRuby.Ruby.CreateEngine(); > engine.Execute("puts ''hello ironruby''"); > } > > but how can I execute a rake task without using another .rb file. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100114/ce5b990f/attachment.html>
This works if I create a ruby file and execute it like this: ir something.rb but it does not work using the following code: static void Main(string[] args) { var script = @"require ''rubygems'' require ''rake'' require ''rakefile''; Rake::Task[''foo''].execute"; var engine = IronRuby.Ruby.CreateEngine(); engine.Execute(script); } Exception is: Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load -- rubyge ms at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame fram e) at Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(InterpretedFra me frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 a rg1) at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean bindGlobals) at IronRuby.Runtime.RubyScriptCode.Run() at Microsoft.Scripting.SourceUnit.Execute() at Microsoft.Scripting.Hosting.ScriptSource.Execute() at Microsoft.Scripting.Hosting.ScriptEngine.Execute(String expression) at ConsoleApplication2.Program.Main(String[] args) in C:\Projects\EStudyVS200 8\EStudySoltution\EStudy\ConsoleApplication2\Program.cs:line 20 Press any key to continue . . . -- Posted via http://www.ruby-forum.com/.
Hosting IronRuby in C# requires a little bit of configuration. Copy the entire contents of ir.exe.config into your C# project''s app.config. Take a look at the LibraryPaths setting to make sure any relative paths still make sense, and then any Ruby libraries or gems that work at the command line will also work when hosted. And Mohammad, the bring everything into perspective, "../../rake foo" isn''t valid Ruby code =) ~Jimmy> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Mohammad Azam > Sent: Thursday, January 14, 2010 1:47 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Executing irake from C# > > This works if I create a ruby file and execute it like this: > > ir something.rb > > but it does not work using the following code: > > static void Main(string[] args) > { > var script = @"require ''rubygems'' > require ''rake'' > > require ''rakefile''; > > Rake::Task[''foo''].execute"; > > var engine = IronRuby.Ruby.CreateEngine(); > engine.Execute(script); > > } > > Exception is: > > > Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load > -- rubyge > ms > at > Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame > fram > e) > at > Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(InterpretedFra > me frame) > at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame > frame) > at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 > arg0, T1 a > rg1) > at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean > bindGlobals) > at IronRuby.Runtime.RubyScriptCode.Run() > at Microsoft.Scripting.SourceUnit.Execute() > at Microsoft.Scripting.Hosting.ScriptSource.Execute() > at Microsoft.Scripting.Hosting.ScriptEngine.Execute(String > expression) > at ConsoleApplication2.Program.Main(String[] args) in > C:\Projects\EStudyVS200 > 8\EStudySoltution\EStudy\ConsoleApplication2\Program.cs:line 20 Press any key > to continue . . . > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
When you create an engine, it doesn''t get the ScriptSetup that goes with it. If you include the xml elements from ir.exe.config into your apps config, it should get the right stuff. JD -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam Sent: Thursday, January 14, 2010 1:47 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Executing irake from C# This works if I create a ruby file and execute it like this: ir something.rb but it does not work using the following code: static void Main(string[] args) { var script = @"require ''rubygems'' require ''rake'' require ''rakefile''; Rake::Task[''foo''].execute"; var engine = IronRuby.Ruby.CreateEngine(); engine.Execute(script); } Exception is: Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load -- rubyge ms at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame fram e) at Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(InterpretedFra me frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 a rg1) at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean bindGlobals) at IronRuby.Runtime.RubyScriptCode.Run() at Microsoft.Scripting.SourceUnit.Execute() at Microsoft.Scripting.Hosting.ScriptSource.Execute() at Microsoft.Scripting.Hosting.ScriptEngine.Execute(String expression) at ConsoleApplication2.Program.Main(String[] args) in C:\Projects\EStudyVS200 8\EStudySoltution\EStudy\ConsoleApplication2\Program.cs:line 20 Press any key to continue . . . -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core