build .net solution from batch file

為{幸葍}努か 提交于 2019-12-03 07:17:09

问题


I have a solution file comprising of 15 projects using a few third party dll references. I want to be able to build the solution from a batch file. What is the best way to do this?

Thanks


回答1:


Run msbuild - for example:

msbuild MySolution.sln /p:Configuration=Release /p:Platform="Any CPU"



回答2:


One of the simplest ways is to execute msbuild with the solution file as input:

@echo off
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe path\to\solution.sln

If this is done in a Visual Studio command prompt you can skip the path to msbuild.exe.




回答3:


One way to get started is to open the project in Visual Studio and select Build | Rebuild Solution. Then go to View | Output. In the output window select "Build" in the Show Options From dropdown. This will display the commands that Visual Studio is using to build the project. You can paste those into a batch file, and read or modify them as desired.

If you want to maintain both Debug and Release versions of your application, then you will want to select the correct configuration and then follow the above steps for each version.



来源:https://stackoverflow.com/questions/3885275/build-net-solution-from-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!