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 9249957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:19:43+00:00 2026-06-18T10:19:43+00:00

We have written a custom msbuild task that does some pre-processing of code files

  • 0

We have written a custom msbuild task that does some pre-processing of code files within our project. What we want to be able to do is to display the errors and warnings in the standard Error List window.

Visual Studio offers the TaskLoggingHelper (Log.LogError) method that is supposed to do this… but I have found that the Log.LogError(message, messageArgs) does not fill in the correct file name and line number… and the Log.LogError(subCategory, errorCode, helpKeyword, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, messageArgs) returns with an error stating that message cannot be null even when I have explicitly set this.

It’s seems that Visual Studio might not be using the overloaded (more detailed) method.

The code line I am sending is as follows..

string fileName = "main.c";
int lineNum = 415;
int colNum = 5;
string message = "Error Message Text.";

Log.LogError("", "", "", fileName, lineNum, colNum, 0, 0, message, null); 

Has anyone successfully used this method overload to log an error in MSBuild??

Thanks

** UPDATE **

After reading Nick’s response (below) I did the following test…

Log.LogError("test1", "test2", "test2", fileName, lineNum, colNum, 0, 0, message);

I removed the messageArgs and added some text to the first three parameters. The response I got was surprising… The message listed in the ErrorList window was “test1” and not “Error Message Text”. Not sure this shines any light on situation though.

Dave

  • 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-06-18T10:19:44+00:00Added an answer on June 18, 2026 at 10:19 am

    Okay after poking this problem for a LONG time.. I was never able to get the Log.LogError(“”, “”, “”, fileName, lineNum, colNum, 0, 0, message, null); solution to work. For whatever reason it appears that this overload is not implimented correctly. I ended up finding an alternate solution that does the same thing. I thought it would be good to supply my solution in case someone else wants to do the same;

    BuildErrorEventArgs errorEvent = new BuildErrorEventArgs("", "", fileName, lineNum, colNum, 0, 0, messageErr, "", "");
    BuildEngine.LogErrorEvent(errorEvent);
    

    So what I did was to implement the IBuildEngine interface as part of my ITask class. From that I was able to access the LogErrorEvent which allows you to pass the BuildErrorEventArgs structure that gives you access to all the detail information for the error.

    Hope this helps

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

Sidebar

Related Questions

I have written some custom R code that wraps a third-party binary. One of
I have written a custom interceptor that does some parameter validation. I want to
I have written a custom MSBuild task, call it TaskA, that parses a file
I'm using nant to build our product and have written a custom task to
I've written a custom MSBuild task to generate model code from MSSQL stored procedures.
I have written a custom control that renders some graphics. The graphics itself is
I have written a few MSBuild custom tasks that work well and are use
For an integration test setup, we have written some custom scripts and code to
I have written a custom Windows Service that writes data to a custom Event
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl

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.