How call .NET command prompt
How to call .NET command prompt from Aspx to Build/Publish another windows application.
I have a windows application, that I want to build via my web a开发者_StackOverflow社区pplication (aspx). How can I do that?
You want to build from aspx? Odd, but... Ultimately you have Process.Start
which can execute any command, but you should think very carefully about which security context / identity your web-server is running as, and where it can read / write files, and the impact of using a web-server as a build-server.
Another option is to use the web-server to queue the work (perhaps MSMQ etc), and have a separate service (on a separate machine) dequeuing and doing the build / publish.
You'll want to use the System.Diagnostics.Process object to spawn another task. You probably don't want a command prompt. Instead, you'll want to call MSBUILD.EXE directly and pass in a target of "Publish".
msbuild.exe /t:Publish MySolution.sln
This is how you execute a command, and the command you want to execute is MSBuild
Write a .bat file that calls csc.exe or msbuild or whatever with the appropriate parameters. Execute the bat with System.Diagnostics.Process.Start method. You may need to set appropriate permissions for the web application process
精彩评论