Kman
Kman

Reputation: 81

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

Upvotes: 0

Views: 613

Answers (4)

Adrian Zanescu
Adrian Zanescu

Reputation: 8008

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

Upvotes: 0

Dave Markle
Dave Markle

Reputation: 97671

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

Upvotes: 2

Marc Gravell
Marc Gravell

Reputation: 1062492

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.

Upvotes: 2

David Hedlund
David Hedlund

Reputation: 129782

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

Upvotes: 0

Related Questions