Reputation: 4716
I want to run some custom batch code just before every build. In a VS<11/C# app I could set the pre-build events in the project settings. I can't find similar settings in a javascript metro VS11 solution.
Anyone know where it is, or if the option is gone (!) what kind of workaround I can do in its place?
Upvotes: 2
Views: 1162
Reputation: 1480
You can use the BeforeBuild target in the Visual Studio .jsproj file to accomplish this:
<Target Name="BeforeBuild"></Target>
<Target Name="AfterBuild"></Target>
To get here:
Uncomment the BeforeBuild target and add your custom step inside of it. You can use the element to execute a command line script; the same $ variables are available as in C# pre-build steps (e.g. $(ProjectDir)). You can do more than call command line scripts in a Target, but this is closest to what you would normally do with C# pre-build steps.
As an example, the following code would call a batch file named processFile.bat passing it a path to default.js in the project root and an output path to create a file named output.js in the project's output directory (e.g. /bin/Debug in Debug mode):
<Target Name="BeforeBuild">
<Exec Command="processFile.bat "$(ProjectDir)default.js" "$(OutDir)output.js"">
</Target>
Note: The " is on purpose inside of the Command arguments, this makes sure the two parameters are quoted when passed to processFile.bat and called via cmd.exe.
Upvotes: 7