English 中文(简体)
How do I create a pre-build step for a javascript metro app in VS11?
原标题:

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?

最佳回答

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.

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签