How do I create a pre-build step for a javascript metro app in VS11?

风格不统一 提交于 2019-11-30 16:19:09

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:

  1. Right-click your project in Visual Studio and choose Open Folder in Windows Explorer
  2. In Explorer, right-click the .jsproj file and choose Open With... and choose an editor like Notepad
  3. Scroll to the bottom of the file and you'll notice these two Target sections commented out

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 &quot;$(ProjectDir)default.js&quot; &quot;$(OutDir)output.js&quot;">
</Target>

Note: The &quot; 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!