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

  • SEARCH
  • Home
  • 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 103741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:10:18+00:00 2026-05-11T01:10:18+00:00

Environment: C# projects, Visual studio 2008, C#, .Net 3.5, MSBuild Objective: Run my own

  • 0

Environment:

C# projects, Visual studio 2008, C#, .Net 3.5, MSBuild

Objective:

Run my own custom build task for my C# projects, and based on the platform (Soln configuration platform), I do some manipulations to the Project object itself before build. Like setting BuildAction to EmbeddedResource etc.

Once that’s done I call Project.Build(). I don’t want to use the Project object on the GlobalEngine, because it is going to mark the file dirty (and checkout from TFS), once you modify the Project object in anyway.

Problem:

Because I am using my own instance of the Engine, and Project, I am not able to direct the build output, errors to VS. I only get a bool out of Project.Build(). I don’t find any events I could hook up to that can allow access to BuildErrorEventArgs and things like that. I know I can use Log.LogErrorEvent() to log messages to VS error list. But I need to get the build output itself first to do that.

Code:

// Execute method in my custom build task class, derives from a BaseTask class public override bool Execute() { Engine engine = new Engine(); Project project = new Project(engine); project.Load(ProjectName); Log.LogMessage(Microsoft.Build.Framework.MessageImportance.High, 'Got the Project'); // Set the project's DefaultTargets to 'Build' to be able to build with CSharp targets project.DefaultTargets = 'Build'; IsBuilt = project.Build(); // Isbuilt bool is a property in my BaseTask class // Here's where I want to get Build output and direct it to VS output window and errorlist window  engine.Shutdown(); return base.Execute(); } 
  • 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. 2026-05-11T01:10:18+00:00Added an answer on May 11, 2026 at 1:10 am

    I figured it out, simply implement a custom logger and use Log.LogMessage or LogError in the event handlers

    public class MyCustomBuildLogger : ILogger {     private IEventSource source;   public void Initialize(IEventSource eventSource)         {             this.source = eventSource;             //Events.ProjectStarted += new ProjectStartedEventHandler(Events_ProjectStarted);             //Events.ProjectFinished += new ProjectFinishedEventHandler(Events_ProjectFinished);             Events.WarningRaised += new BuildWarningEventHandler(Events_WarningRaised);             Events.ErrorRaised += new BuildErrorEventHandler(Events_ErrorRaised);             Events.BuildFinished += new BuildFinishedEventHandler(Events_BuildFinished);             //Events.BuildStarted += new BuildStartedEventHandler(Events_BuildStarted);             Events.MessageRaised += new BuildMessageEventHandler(Events_MessageRaised);             //Events.CustomEventRaised += new CustomBuildEventHandler(Events_CustomEventRaised);              Events.MessageRaised += new BuildMessageEventHandler(Events_MessageRaised);         }   void Events_ErrorRaised(object sender, BuildErrorEventArgs e)         {             // This logs the error to VS Error List tool window             Log.LogError(String.Empty,                 String.Empty,                     String.Empty,                      e.File,                      e.LineNumber,                      e.ColumnNumber,                     e.LineNumber,                      e.ColumnNumber,                      e.Message);            } } 

    and in the MyCustomBuildTask class, where you setup and load the engine and project,

    _logger = new MyCustomBuildLogger(); _logger.Log = Log; _engine.RegisterLogger(_logger); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Environment: Team Foundation Server 2005 Visual Studio 2008 I have a reasonably large project
I have two questions re: visual studio 2008 and post-build events. 1) How do
I have created a strongly signed assembly in Visual Studio 2008 against the .NET
I'm migrating a solution from visual studio 2005 to visual studio 2008. When I
I have developed a build system on MSBuild (NET 3.0) and cc.net to perform
yesterday afternoon Visual Studio 2008 suddenly started taking a really long time to open
I have a new Visual Studio 2008 Database Project (Data Dude). It was generated
My environment consists of Visual Studio 2010 and Windows 7 a few months ago
I'm having a little trouble building my application as Release in Visual Studio 2008.
In visual studio 2008 or 2010, the option to debug in a local IIS

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.