I am working on WPF project developed in visual studio 10. I want to create a batch file so that I can run .bat file without opening VS10 solution and find errors if there are any. I referred this link but I dont understand how the commands msbuild,Configuration & platform work.
1 Answer
MSBuild is the underlying program that Visual Studio uses to build .NET applications. It comes with the .NET Framework and does not require Visual Studio to run. The build Configuration is typically Release or Debug and determines how the application is built (e.g. optimized for size and speed or for ease of debugging). The build Platform is typically x86, x64, or Any CPU and determines which CPU architecture the assembly should target.
To build from the command line you can create a batch file that contains the following:
@echo off
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Projects\YourProject.sln
Obviously replace the path to C:\Projects\YourProject.sln with the path to your solution file, it can also be relative such as just YourProject.sln if the batch file is executed in the same directory as your solution. The Configuration and Platform are optional and will default to Debug and x86 for Visual Studio 2010. However, if you want to specify the Configuration and Platform you can do so as follows:
@echo off
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Projects\YourProject.sln /p:Configuration=Release /p:Platform="Any CPU"
For more information on msbuild you can type the following at the command prompt:
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe /?
There are a ton of options so check out the documentation on MSDN for more details.