4

I wanna use msbuild in C#, there are 2 approach:
we have a build engine to compile some xmls, and the engine has its own logging system.

1) Call msbuild in C#

Process P=new Process();
p.StartInfo.FileName=...

This works, but I wanna a more programically way.

2) Use Microsoft.Build namespace

BuildManager.DefaultBuildManager.Build(
                new BuildParameters()
                {
                    DetailedSummary = false,
                    Loggers = new List<ILogger>() { logger }
                }, buildRequest);

The Question is, I can't use the build engine logging system, let's say, the Microsoft.Build Logger returns the build result but not that useful, our build engine's logger can figure out more detail information on errors.
Since Microsoft.Build also use *.vproj and the assembly dlls works fine, is there a way to use customer build engine's logger and out put somewhere...

Nandu
  • 3,076
  • 8
  • 34
  • 51
L_G
  • 209
  • 2
  • 10
  • Not sure what your problem is - in code you've shown you pass custom `logger` which can listen (and repot wherever you want) to all events reported by the build... Or you want separate unrelated log system? – Alexei Levenkov Apr 03 '13 at 03:10
  • if i use msbuild /t:buildfile /p:targetfile=xxx.xml /fileloggerparameters:logfile=C:\test.log, then I can see the log as:xxx.xml(163,34): error V0210: xxx.xml(163,34): Error V0210: Failed to xxx. while the Microsoft.Build shows sth like:ERROR (-1,-1): Error : Unable to cast COM object of type 'System.__ComObject' to... – L_G Apr 03 '13 at 03:17
  • I can see from the output window: Loaded 'C:\xxxLogging.dll', Symbols loaded. But, if i use Microsoft.Build.Execution.BuildManager in C# to build the project, how to catch xxxLogging rather than BuildManager's log info? – L_G Apr 03 '13 at 03:23
  • 1
    possible duplicate of [Logging Build messages with MSBuild 4.0](http://stackoverflow.com/questions/3990386/logging-build-messages-with-msbuild-4-0) – KMoraz Apr 03 '13 at 22:50

0 Answers0