Running the node utility inliner from Visual Studi

2019-09-09 21:29发布

问题:

This follows on from this question.

I have a windows service application where I want to serve out a single html page to display simple runtime information for the service. I found the utility inliner which allows me to combine my web files into a single html file, which is easy to serve up via self hosted web api running in the windows service.

I would like to auto run the script to build this single html file, so I put the command line into a .bat/.cmd file and then call this from Visual Studio 2015 post build event. The source html file has a couple of references to scripts and css, eg

<head>
  <link href="lib\css\bootstrap.css" rel="stylesheet" type="text/css" />
  <script src="lib\js\jquery-2.2.1.js"></script>
  <script src="_default.js"></script>
</head>

The contents of the .cmd (or .bat) file are as follows

echo %1
cd %1
dir .
where inliner
inliner -vs _default.html > default.html

In the Visual Studio post build, I have have

call "$(ProjectDir)\WebAdminPanel\build.bat" "$(ProjectDir)\WebAdminPanel"

The echo and dir. are just debug output so I could see the directory was correctly changed (I thought this may be the issue)

The batch file (that now works when I run it manually), does run, but I still get an empty output file.

The -v flag should make the utility run verbose, but I do not see any output from in the Visual Studio output window; perhaps this would help to see what is going wrong. I am suspected perhaps it is not finding the includes, but not sure.

Is there anyone familiar with this utility and perhaps know why it fails when I run it as a Visual Studio post build task?

Thanks in advance for any help.

(EDIT)

In the visual studio output window I see

1> Directory of H:\dev\myapp\WebAdminPage
1>
1>  11/03/2016  03:10 PM    <DIR>          .
1>  11/03/2016  03:10 PM    <DIR>          ..
1>  11/03/2016  03:10 PM                79 build.bat
1>  11/03/2016  03:09 PM               182 default.html
1>  07/03/2016  12:41 PM    <DIR>          lib
1>  10/03/2016  11:12 PM             2,025 _default.html
1>  10/03/2016  11:06 PM             2,412 _default.js
1>                 4 File(s)          4,698 bytes
1>                 3 Dir(s)  1,376,883,204,096 bytes free
1>  C:\Users\peterc\AppData\Roaming\npm\inliner
1>  C:\Users\peterc\AppData\Roaming\npm\inliner.cmd