2012-03-27 53 views
0

我正在尝试将项目集成到具有两个组件的客户端(用silverlight编写)和服务器(用java编写)中。服务器端完全兼容maven,但我遇到了使用maven运行msbuild的问题。我收到以下拒绝访问错误从maven调用msbuild时出错

嵌入式错误:无法运行程序“C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.3031 9 \ msbuild”(在目录“C:\ workspace \ something \ client” ):CreateProcess的错误= 5, 访问被拒绝

机:的Windows XP 壳:git的庆典和CMD

的pom.xml:

 <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"> 
     <modelVersion>4.0.0</modelVersion> 
     <groupId>x</groupId> 
     <artifactId>client</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
     <packaging>pom</packaging> 
     <name>client</name> 
    <build> 
     <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <configuration> 
       <executable>${msbuild.path}</executable> 
      </configuration> 
      <executions> 
       <execution> 
       <id>clean</id> 
       <phase>clean</phase> 
       <configuration> 
       <arguments> 
       <argument>/t:Clean</argument> 
       </arguments> 
      </configuration> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      </execution> 
      <execution> 
      <id>build</id> 
      <phase>compile</phase> 
      <configuration> 
       <arguments> 
       <argument>/t:some.sln</argument> 
       </arguments> 
      </configuration> 
       <goals> 
        <goal>exec</goal> 
       </goals> 
      </execution> 
      </executions> 
     </plugin> 
     </plugins> 
    </build> 
    </project> 

错误:

 $ 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.<init>(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: < 1 second 
    [INFO] Finished at: Tue Mar 27 10:33:58 CDT 2012 
    [INFO] Final Memory: 7M/494M 
    [INFO] ------------------------------------------------------------------------ 

任何人都有成功使用maven/java或使用maven在运行任何Windows程序/批处理文件运行的MSBuild?

+0

将msbuild放在路径中并避免长路径名可能会更好。他们总是似乎造成麻烦.. – 2012-03-27 20:52:14

回答

1

移动到Windows 7,它的工作原理。不知道为什么它不能在XP上工作,但它解决了我的问题。

2

可能因为您的${msbuild.path}属性解析为C:\Windows\...\msbuild这是一个文件夹,而不是C:\Windows\...\msbuild.exe,可执行文件。

+0

我在命令窗口中测试了我不需要“.exe”,但是当我使用System.Diagnostics.Process.Start时,我确实需要“.exe”。谢谢。 – leem 2015-01-24 23:47:32