tags:

views:

79

answers:

1

I'd like to avoid a command line for this. I've been using the MSBuild API ( Microsoft.Build.Framework and Microsoft.Build.BuildEngine) with code that looks like this:

this.buildEngine = new Engine();
BuildPropertyGroup props = new BuildPropertyGroup();
props.SetProperty("Configuration", "Debug");
this.buildEngine.RegisterLogger(this.logger);
Project proj = new Project(this.buildEngine);
proj.LoadXml(this.projectFileAndPath, ProjectLoadSettings.None);
this.buildEngine.BuildProject(proj, "Build"); 

However I've run into enough problems that I can't find answers for that I'm really wondering if I'm doing this right. First, I can't find the output (there's no bin directory in any of the places where I figured the dll's would end up). Second, I tried building a project that I had made in VS2008 and the line proj.LoadXml( fails for invalid xml encoding. But of course the xml file is valid, since VS2008 can build it (I checked).

At this point I'm beginning to wonder if I've picked up some code that's way out of date or a methodology that's been superseded by something else. Opinions?

+1  A: 

The LoadXml() method expects a string that contains the xml, not a path to a file. Use the Load() method instead.

No, there's nothing out-of-date about the Microsoft.Build namespace. Assuming you are using the 3.5 version.

Hans Passant
/headslap; jeez I feel dumb now.
jcollum
I'm still stuck on where exactly that output is going. I did get it to build successfully earlier (had to change over to this code because my end result is going into IlMerge and it had a hard time resolving the .NET framework location...) but there was still no actual output.
jcollum