2011-11-02 37 views
2

我被要求將VB.NET解決方案從Windows Server 2003,Visual Studio 2005,32位,.NET 2.0遷移到Windows Server 2008,Visual Studio 2008,64位。 NET 4.0。我有解決方案編譯並在Visual Studio中正常工作。下一步就是讓Nant腳本工作,以便像以前那樣進行結帳,編譯和測試。Nant腳本不能生成msbuild

然而,當南特腳本獲取到的MSBuild一步,它立即與失敗「...... Microsoft.NET/Framework64/v4.0.30319/msbuild啓動失敗。訪問被拒絕」

我已經嘗試使用相同的輸入直接運行msbuild,並通過這一點。我的問題是:有沒有什麼我可以放在我的nant .build中讓它以管理員身份運行它的任務?

我.build文件:

<?xml version="1.0"?> 
... 
<credential domain="xxxx" username="xxxxx" password="xxxxxx" id="55" /> 
<property name="debug" value="true" overwrite="false" /> 
<property name="configuration" value="debug" overwrite="false" /> 
<property name="solution.file" value="solution.sln" overwrite="false" /> 
... 
<target name="msbuild" description="Build the whole solution"> 
<exec program="C:/Windows/Microsoft.NET/Framework64/v4.0.30319/msbuild" workingdir="D:/BuildTest" commandline='"${solution.file}" /v:q /nologo /p:Configuration=${configuration}' /> 
</target> 
... 

回答

1

我有一個32位的機器上同樣的問題。對我來說,解決方法是使用nantcontrib的msbuild任務。任何人都明白爲什麼這可行?

在64位計算機上,exec方法也適用。我必須在正確的Framework文件夾中指向msbuild.exe。

<target name="compile" description="Compiles the .Net solution"> 

    <!-- this works --> 
    <msbuild project="${src.root.dir}\${src.solution}" 
        verbosity="Normal"> 
     <arg value="/p:Configuration=${msbuild.configuration}" /> 
     <arg value="/p:Platform=Any CPU" /> 
     <arg value="/t:Rebuild" /> 
     <arg value="/nologo" /> 
    </msbuild> 

    <!-- access is denied --> 
    <exec program="${msbuild.path}" 
      workingdir="${src.root.dir}" 
      basedir="${src.root.dir}" 
      commandline="${src.root.dir}\${src.solution}${src.solution}" 
      failonerror="true" > 
     <arg value="/p:Platform=Any CPU" /> 
     <arg value="/p:Configuration=${msbuild.configuration}" /> 
     <arg value="/t:Rebuild" /> 
     <arg value="/v:${msbuild.verbosity}" /> 
    </exec> 
</target> 
+0

是啊,這做到了。謝謝!! – user1026655

2

或者

你可以把名爲 「.exe」 的結束,如果行的MSBuild

<exec program="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"> 
+0

該解決方案在應用於ProcessStartInfo時也可以工作。謝謝! – SingleStepper