TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jan Rosgaard
NA
1
0
MSBuild and error logging
Dec 9 2009 6:41 AM
Hi,
In the project I'm currently working on I have in my .vsproj file a reference to a "targets" file, i.e. something like this:
<Import Project="SomePath\SomeProject.targets" />
SomeProject.targets refers to a number of .exe files, which are all part of our tool chain. That is, every time we build our Visual Studio project, a number of tools will run in the background. The tools take care of various tasks, e.g. graphics file conversion etc. The tools are developed by us and they are all console apps that make use of Console.WriteLine(). When we build the proejct, we see the output from the tools in Visual Studio's "Output" pane. So far so good.
In the event that one of our tools encounter an error the build process stops (as it should), but the problem is that Visual Studio jumps to the "Error List" pane and writes something similar to this:
Error 2 The command "SomeTool.exe" exited with code 1.
And this is where the real problem is. I would like to print the error message from the tool in question instead. How to do that?
I was planning to solve the problem as follows:
Modify our .targets file so it no longer directly refers to our tools but instead refers to a new tool written by me. That is:
<Exec Command="SomeTool.exe <param1> <param2>"/>
is changed to:
<Exec Command="MyTool.exe <SomeTool.exe> <param1> <param2>"/>
In MyTool.exe I do the following:
// TaskWrapper inherits Microsoft.Build.Utilities.Task
Task task = new TaskWrapper();
// BuildEngineStub implements Microsoft.Build.Framework.IBuildEngine and IEventSource
BuildEngineStub engine = new BuildEngineStub( task );
ConsoleLogger logger = new ConsoleLogger();
logger.Initialize( engine );
// Execute() instantiates a ProcessStartInfo object og launches SomeTool.exe with the specified parameters.
task.Execute();
I had hoped that, since it is my tool that launches the various tools in our tool chain and since my tool implements IBuildEngine, perhaps it would be possible to show custom error messages in the "Error List" pane within Visual Studio. I can't seem to get it working, though, so I would like some opinions as to whether I'm on the right track or not.
Thanks in advance,
Mikkel
Reply
Answers (
1
)
constraints on generics
Do not close ContextMenuStrip