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

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sorry but it is not possible. According to JPA specification,… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer To get this event to fire, the page needs to… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer I found that "exit 0" looks like a good way… May 12, 2026 at 12:15 am

Related Questions

I am preparing for the development of an enterprise-style application for a very small
For my project I have settings that I added through the Settings in the
I'm migrating a solution from visual studio 2005 to visual studio 2008. When I
I am working in a Visual Studio 2008 solution with multiple C# projects and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.