Building C# solutions from command line with Visual Studio 2010

C#Visual StudioBuildBuild ProcessBuild Automation

C# Problem Overview

I want to automate the build process for my C# solutions. How can I build C# solutions from the command line so that I don't have to deal with dependencies manually?

C# Solutions

Solution 1 - C#

For solutions you can use:

devenv /build Release Solution.sln


devenv /build Debug Solution.sln

Solution 2 - C#

if you open a visual studio command prompt from your start menu - then you can call MSBuild and give that either the .sln file or a specific .csproj file in order to build what you need

alternatively you can create a custom MSBuild file that takes care of the tasks.

one tip: make sure the version of MSBuild that you use is applicable to the target framework or tools version of the project

i.e. if you try and build a solution that was created in vs2010 with msbuild 3.5 then it will not recognise the 4.0 toolset of the project

Solution 3 - C#

Visual Studio project and solution files are also MSBuild build files.

You can simply run MSBuild against the solution/project file and it will build:

<path to>msbuild.exe <path to>solution/project file

Solution 4 - C#

msbuild YourSolution.sln

Solution 5 - C#

Personally I'm a huge fan of Rake (yeah - I heard you when you said your c# solution)

Check it out:

Have fun - it made life a lot better for me!

Solution 6 - C#

you can use the c# (csc.exe) compiler directly:

Command-line building with csc.exe


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionalexfrView Question on Stackoverflow
Solution 1 - C#NateView Answer on Stackoverflow
Solution 2 - C#stack72View Answer on Stackoverflow
Solution 3 - C#OdedView Answer on Stackoverflow
Solution 4 - C#Steve MichelottiView Answer on Stackoverflow
Solution 5 - C#PaulView Answer on Stackoverflow
Solution 6 - C#STWView Answer on Stackoverflow