views:

102

answers:

4

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 application (aspx). How can I do that?

A: 

This is how you execute a command, and the command you want to execute is MSBuild

David Hedlund
+2  A: 

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.

Marc Gravell
Or you could just download CruiseControl.NET or Hudson... Sigh.
Dave Markle
+2  A: 

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

Dave Markle
A: 

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

AZ