title: error calling msbuild from maven
body: <p>I'm trying to integrate a project into maven having two components - client (written in silverlight) and server (written in java). The server side is fully maven compatible but I'm having issues running msbuild using maven. I get the following access denied error </p>
  
  <p>Embedded error: Cannot run program "C:\WINDOWS\Microsoft.NET\Framework\v4.0.3031
  9\msbuild" (in directory "C:\workspace\something\client"): CreateProcess error=5,
   Access is denied</p>
  
  <p>Machine: <strong>Windows XP</strong>
  shell: <strong>git bash and cmd</strong></p>
  
  <p>pom.xml:</p>
  
  <pre><code>        &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
        &lt;groupId&gt;x&lt;/groupId&gt;
        &lt;artifactId&gt;client&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;packaging&gt;pom&lt;/packaging&gt;
        &lt;name&gt;client&lt;/name&gt;
       &lt;build&gt;
         &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;executable&gt;${msbuild.path}&lt;/executable&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                   &lt;execution&gt;
                   &lt;id&gt;clean&lt;/id&gt;
                   &lt;phase&gt;clean&lt;/phase&gt;
                   &lt;configuration&gt;
                  &lt;arguments&gt;
                  &lt;argument&gt;/t:Clean&lt;/argument&gt;
                  &lt;/arguments&gt;
               &lt;/configuration&gt;
               &lt;goals&gt;
                   &lt;goal&gt;exec&lt;/goal&gt;
               &lt;/goals&gt;
               &lt;/execution&gt;
               &lt;execution&gt;
               &lt;id&gt;build&lt;/id&gt;
               &lt;phase&gt;compile&lt;/phase&gt;
               &lt;configuration&gt;
                   &lt;arguments&gt;
                  &lt;argument&gt;/t:some.sln&lt;/argument&gt;
                   &lt;/arguments&gt;
               &lt;/configuration&gt;
                   &lt;goals&gt;
                      &lt;goal&gt;exec&lt;/goal&gt;
                   &lt;/goals&gt;
               &lt;/execution&gt;
             &lt;/executions&gt;
          &lt;/plugin&gt;
        &lt;/plugins&gt;
       &lt;/build&gt;
      &lt;/project&gt;
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>        $ mvn compile -Dmsbuild.path=C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/msbu
      ild -e
      + Error stacktraces are turned on.
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building client
      [INFO]    task-segment: [compile]
      [INFO] ------------------------------------------------------------------------
      [INFO] [exec:exec {execution: build}]
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Command execution failed.
  
      Embedded error: Cannot run program "C:\WINDOWS\Microsoft.NET\Framework\v4.0.3031
      9\msbuild" (in directory "c:\workspace\something\client"): CreateProcess error=5,
       Access is denied
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.lifecycle.LifecycleExecutionException: Command execution failed
      .
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
      ultLifecycleExecutor.java:719)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
      fecycle(DefaultLifecycleExecutor.java:556)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
      ltLifecycleExecutor.java:535)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
      dleFailures(DefaultLifecycleExecutor.java:387)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
      ts(DefaultLifecycleExecutor.java:348)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
      fecycleExecutor.java:180)
              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
              at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
      0)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
              at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
              at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
  
              at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution fai
      led.
              at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:363)
              at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
      nManager.java:490)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
      ultLifecycleExecutor.java:694)
              ... 17 more
      Caused by: java.io.IOException: Cannot run program "C:\WINDOWS\Microsoft.NET\Fra
      mework\v4.0.30319\msbuild" (in directory "c:\workspace\something\client"): Create
      Process error=5, Access is denied
              at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
              at java.lang.Runtime.exec(Runtime.java:593)
              at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13Com
      mandLauncher.java:58)
              at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:2
      54)
              at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecut
      or.java:319)
              at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:
      160)
              at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:602)
  
              at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:348)
              ... 19 more
      Caused by: java.io.IOException: CreateProcess error=5, Access is denied
              at java.lang.ProcessImpl.create(Native Method)
              at java.lang.ProcessImpl.&lt;init&gt;(ProcessImpl.java:81)
              at java.lang.ProcessImpl.start(ProcessImpl.java:30)
              at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
              ... 26 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: &lt; 1 second
      [INFO] Finished at: Tue Mar 27 10:33:58 CDT 2012
      [INFO] Final Memory: 7M/494M
      [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Anyone have success running msbuild using maven/java or running any windows process/batch file using maven?</p>