user1699826
user1699826

Reputation: 21

Set Visual Studio 2010 properties programmatically

I am creating an application which build the code.But i want to set the Visual studio 2010 properties programmatically.

For example, I want to set INCLUDE Directories, Reference directories, Library Directories this all directories which will be set from the VS GUI but i want this programmatically.

Upvotes: 1

Views: 551

Answers (1)

Hassan Boutougha
Hassan Boutougha

Reputation: 3919

you can see msdn article to do this:http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.engine.buildprojectfile(v=vs.90).aspx

    using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.BuildEngine;

namespace BuildAProjectCS
{
    class Program
    {       
        static void Main(string[] args)
        {
            // Instantiate a new Engine object
            Engine engine = new Engine();

            // Point to the path that contains the .NET Framework 2.0 CLR and tools
            engine.BinPath = @"c:\windows\microsoft.net\framework\v2.0.xxxxx";


            // Instantiate a new FileLogger to generate build log
            FileLogger logger = new FileLogger();

            // Set the logfile parameter to indicate the log destination
            logger.Parameters = @"logfile=C:\temp\build.log";

            // Register the logger with the engine
            engine.RegisterLogger(logger);

            // Build a project file 
            bool success = engine.BuildProjectFile(@"c:\temp\validate.proj");

            //Unregister all loggers to close the log file
            engine.UnregisterAllLoggers();

            if (success)
                Console.WriteLine("Build succeeded.");
            else
                Console.WriteLine(@"Build failed. View C:\temp\build.log for details");

        }
    }
}

Upvotes: 1

Related Questions