MSBuild and Webpack
<p>I am developing an Angular2 application in VS2015 and have a webpack bundling and minification environment set up for the same.</p>

<p>This is my webpack.conf.js</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>switch (process.env.NODE_ENV) {
    case 'prod':
    case 'production':
        module.exports = require('./config/webpack.prod');
        break;
    case 'test':
    case 'testing':
        //module.exports = require('./config/webpack.test');
        break;
    case 'dev':
    case 'development':
    default:
        module.exports = require('./config/webpack.dev');
}</code></pre>
</div>
</div>
</p>

<p>I have also installed a webpack task runner which invokes this with the following commands</p>



<pre><code>cmd /c SET NODE_ENV=development&amp;&amp; webpack -d --color
</code></pre>

<p>and</p>

<pre><code>cmd /c SET NODE_ENV=production&amp;&amp; webpack -p --color
</code></pre>

<p>The setup seems to work fine. However, I want to integrate this with my TFS builds CI. The webpack command should fire after the project is built and report a build failure incase the webpack build fails. I have tried to incorporate the following code in my .csproj file</p>

<pre><code>&lt;Target Name="AfterBuild"&gt;
&lt;Exec Condition="$(Configuration) == 'Debug'" Command="cmd /c SET NODE_ENV=production&amp;&amp; webpack -p --color"&gt;
&lt;/Exec&gt;
&lt;/Target&gt;
</code></pre>

<p>It failed with an error 9009</p>

<p>After that I tried, starting the command up from the node_modules folder where webpack was installed</p>

<pre><code>&lt;Target Name="AfterBuild"&gt;
&lt;Exec Condition="$(Configuration) == 'Debug'" Command="./node_modules/.bin cmd /c SET NODE_ENV=production&amp;&amp; webpack -p --color"&gt;
&lt;/Exec&gt;
&lt;/Target&gt;
</code></pre>

<p>still in vain. Even if I get this to work, I am not sure if it would cause the VS build to fail if it encounters an error in webpack. </p>

<p>How do I go ahead with this?</p>