我正在进行一些自动化。我有一个批处理文件,可以编译.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