我正在進行一些自動化。我有一個批處理文件,可以編譯.net解決方案。我希望自動化,但我卡住了。如何編譯.net解決方案並獲取輸出結果?
原始文件:
"B:\Microsoft Visual Studio 9.0\Common7\IDE\devenv" "My_Types\My_Types.sln" /build >> ..\Output\Build.txt
我能得到這個與修改文件的工作:
Compile = New Process()
With Compile.StartInfo
.UseShellExecute = False
.RedirectStandardOutput = True
.FileName = """C:\Code\Intuitive Projects\Build Test.bat"""
End With
bSuccess = Compile.Start()
strOutput = Compile.StandardOutput.ReadToEnd()
Compile.WaitForExit()
MsgBox(strOutput)
修改文件
"B:\Microsoft Visual Studio 9.0\Common7\IDE\devenv" "C:\Code\Intuitive Projects\My_Types\My_Types.sln" /build
但我不能獲得下一步上班。這與爭論有關。
Compile = New Process()
With Compile.StartInfo
.UseShellExecute = False
.RedirectStandardOutput = True
.FileName = "b:\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
'.Arguments = "C:\Code\Intuitive Projects\My_Types\My_Types.sln /build" 'Does nothing
'.Arguments = """C:\Code\Intuitive Projects\My_Types\My_Types.sln"" /build" 'Does nothing
'.Arguments = """""C:\Code\Intuitive Projects\My_Types\My_Types.sln /build""""" 'Opens visual studio and parses the path as two files.
'.Arguments = """""""C:\Code\Intuitive Projects\Projects\My_Types\My_Types.sln"" /build""""" 'Opend the file but I get a message saying files can not be found but there are no files in the list.
'.Arguments = """""""C:\Code\Intuitive Projects\Projects\My_Types\My_Types.sln"" ""/build""""""" 'Tried this because I couldnt think of anything else, fails to find the file "/build"
End With
bSuccess = Compile.Start()
strOutput = Compile.StandardOutput.ReadToEnd()
Compile.WaitForExit()
MsgBox(strOutput)
'msbuild foo.sln' –
您使用的是... PowerShell? VB.NET?你沒有語言標籤,這將有助於指導答覆者。 –
我不知道有另一種方式來編譯C#或VB。添加了標籤。 – Joe