简体   繁体   English

如何调用.NET命令提示符

[英]How call .NET command prompt

How to call .NET command prompt from Aspx to Build/Publish another windows application. 如何从Aspx调用.NET命令提示符以构建/发布另一个Windows应用程序。

I have a windows application, that I want to build via my web application (aspx). 我有一个Windows应用程序,我想通过我的Web应用程序(aspx)进行构建。 How can I do that? 我怎样才能做到这一点?

You want to build from aspx? 您要从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. 奇怪,但是...最终,您具有可以执行任何命令的Process.Start ,但是您应该非常仔细地考虑您的Web服务器运行在哪个安全上下文/身份下,可以在哪里读取/写入文件,以及所产生的影响使用网络服务器作为构建服务器的过程。

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. 另一个选择是使用Web服务器对工作进行排队 (也许是MSMQ等),并使用单独的服务(在单独的计算机上)使队列出队并进行构建/发布。

You'll want to use the System.Diagnostics.Process object to spawn another task. 您将要使用System.Diagnostics.Process对象生成另一个任务。 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并传递“发布”的目标。

msbuild.exe /t:Publish MySolution.sln msbuild.exe / t:发布MySolution.sln

这是执行命令的方式 ,您要执行的命令是MSBuild

Write a .bat file that calls csc.exe or msbuild or whatever with the appropriate parameters. 编写一个.bat文件,该文件调用csc.exe或msbuild或具有适当参数的任何文件。 Execute the bat with System.Diagnostics.Process.Start method. 使用System.Diagnostics.Process.Start方法执行蝙蝠。 You may need to set appropriate permissions for the web application process 您可能需要为Web应用程序过程设置适当的权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM