[근무 일지] VS Code Extension 스터디4

타키탸키·2022년 5월 20일
0

근무 일지

목록 보기
14/16

Node.js에서 exe(C#) 파일 실행하기

Node.js

  • js 파일과 같은 디렉토리 내에 있어야 하는 C# 코드의 산출물
    • dllexe
    • json
      • appname.runtimeconfig.dev.json
      • appname.runtimeconfig.json
var spawn = require('child_process').spawn;

var ipc = spawn("./HelloWorld.exe"); 
ipc.stdin.setEncoding("utf8");

ipc.stderr.on('data', function (data) {
    process.stdout.write(data.toString());
});

ipc.stdout.on('data', function (data) {
    process.stdout.write(data.toString());
});

C#

  • 빌드하여 dllexe 파일 산출
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

        }
    }
}

결과

# terminal
> node sample.js
Hello World!

참고: https://gist.github.com/kevinswiber/1390198
profile
There's Only One Thing To Do: Learn All We Can

0개의 댓글