by Indra
14. December 2010 21:34
These are collection of command line MSBuild that I Use for building and deploying my .Net projects. I use Rake for calling these commands
MSBUILD's parameters are case sensitive!
Updated Dec 17 2011: use the correct OutputPath for console app instead of outdir.
Build whole solution:
Just build whole solution as if pressing ctrl+shift+b from visual studio, does not care where to put the output. Use this when someone commit to trunk to see if the last commited code compiled successfully
"C:\msbuild directory\MSBuild.exe" "D:\path\to\solution\folder\Solution.sln" /p:configuration="Release" /target:Clean;Build
Build Console Application:
Difference with Web App: Use the OutputPath property instead of outdir! DO NOT END the directory path with backslash "\"
"C:\msbuild directory\MSBuild.exe" "D:\path\to\project\folder\ProjectFile.csproj" /p:configuration="Release" /target:Clean;Build /p:OutputPath="c:\path\to\output\bin_NO_BACKSLASH"
Build Web Application Project or Web Service Project:
Output directory has to end with '\'.
Observere output for the bin folder.
"C:\msbuild directory\MSBuild.exe" "D:\path\to\project\folder\ProjectFile.csproj" /p:configuration="Release" /target:ResolveReferences;_CopyWebApplication /p:webprojectoutputdir="c:\\path\\to\\output\\" /p:outdir="c:\\path\\to\\output\\bin\\"
Use double-backslash "\\" or forward slash"/" if you use ' " ' quotes(directory with spaces) for WebProjectOutputDir and OutDir property.
Build Web Site Project Using ASPNET_COMPILER
Use ASPNET_COMPILER.EXE to precompile Web Site Project where no project file can be found (can also be used for ASMX Web Service)
you have to input the /IIS_ApplicationName parameter even though you are not publishing it to IIS!
"C:aspnet_compiler directory\aspnet_compiler.exe" -f -v /IIS_ApplicationName -p c:\source_folder c:\output_folder
LC.EXE and SGEN.EXE
If you do not install .NET SDK on the build machine, you have to add these parameters so MSBUILD can find the LC.EXE and SGEN.EXE
/p:LCToolPath="c:\folder\where\LC_is_located" /p:SGenToolPath="c:\folder\where\SGEN_is_located"