How to create pre-build step of javascript metro app in VS11?

I want to run some custom batch code just before every build. In VS <11 / C # app, I could set pre-build events in project settings. I cannot find similar settings in VS11 solution for javascript metro.

Does anyone know where it is, or if this option is gone (!), What workaround can I do in its place?

+2


source to share


1 answer


You can use the BeforeBuild target in your Visual Studio.jsproj file to accomplish this:

<Target Name="BeforeBuild"></Target>
<Target Name="AfterBuild"></Target>

      

To get here:

  • Right click on your project in Visual Studio and select "Open Folder" in Windows Explorer.
  • In explorer, right click on the .jsproj file and select "Open With ..." and select an editor such as Notepad
  • Scroll down to the bottom of the file and you will notice that these two Target sections are commented out.


Uncomment the BeforeBuild target and add your own step to it. You can use this element to execute a command line script; the same $ variables are available as in the C # pre-build steps (e.g. $ (ProjectDir)). You can do more than invoke command line scripts in Target, but this is closest to what you usually do with the C # pre-build steps.

As an example, the following code will call a batch file named processFile.bat giving it the path to default.js in the project root and the output path to create a file named output.js in the project's output directory (for example, / bin / Debug in debug mode) :

<Target Name="BeforeBuild">
    <Exec Command="processFile.bat &quot;$(ProjectDir)default.js&quot; &quot;$(OutDir)output.js&quot;">
</Target>

      

Note: "is an integral part of the Command arguments, this ensures that two parameters are specified when passed to processFile.bat and invoked via cmd.exe.

+7


source







All Articles