Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:24:53+00:00 2026-05-23T12:24:53+00:00

How do I build a C# solution programmatically? I should be able to pass

  • 0

How do I build a C# solution programmatically?

I should be able to pass the path of a solution and get the output messages (or just build the solution). How do I achieve this in C#?

I need this because we are building a single solution for our projects when it now gets everything from SVN and also builds it. Next would be deploying it all in one click.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:24:54+00:00Added an answer on May 23, 2026 at 12:24 pm

    Most of the answers are providing ways to do it by calling external commands, but there is an API, Microsoft.Build.Framework, to build via C#.


    Code from blog post:

    using Microsoft.Build.BuildEngine;
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;
    
    public class SolutionBuilder
    {
        BasicFileLogger b;
        public SolutionBuilder() { }
    
        [STAThread]
        public string Compile(string solution_name,string logfile)
        {
            b = new BasicFileLogger();
            b.Parameters = logfile;
            b.register();
            Microsoft.Build.BuildEngine.Engine.GlobalEngine.BuildEnabled = true;
            Project p = new Project (Microsoft.Build.BuildEngine.Engine.GlobalEngine);
            p.BuildEnabled = true;
            p.Load(solution_name);
            p.Build();
            string output = b.getLogoutput();
            output += “nt” + b.Warningcount + ” Warnings. “;
            output += “nt” + b.Errorcount + ” Errors. “;
            b.Shutdown();
            return output;
        }
    }
    // The above class is used and compilation is initiated by the following code,
    static void Main(string[] args)
    {
        SolutionBuilder builder = new SolutionBuilder();
        string output = builder.Compile(@”G:CodesTestingTesting2web1.sln”, @”G:CodesTestingTesting2build_log.txt”);
        Console.WriteLine(output);
        Console.ReadKey();
    }
    

    Note the code in that blog post works, but it is a little dated. The

    Microsoft.Build.BuildEngine

    has been broken up into some pieces.

    Microsoft.Build.Construction

    Microsoft.Build.Evaluation

    Microsoft.Build.Execution

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build a DSL Solution using MsBuild and want to be able
I am able to successfully build solution. but i keep getting this when i
This is probably easy but I am getting stuck: when I build a solution
I'm looking to build a solution similar to this one: http://esqinc.com/section/products/4/idocid.html What the system
I'm looking for any solution to get QR Code with soft edge programmatically. Any
So, what I'm actually looking for is this solution: Get/pick an image from Android's
I'd like to be able to build my solution to create 32-bit and 64-bit
What is the difference between Build Solution and Batch Build in Visual Studio 2008?
I normally build my solution with MSBuild in order to keep Visual Studio responsive
Is there anyway to build a solution to target 64 bit environment in vs2003?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.