what's an effective way to build a csproj file in C#?
Posted
by jcollum
on Stack Overflow
See other posts from Stack Overflow
or by jcollum
Published on 2010-03-26T23:01:44Z
Indexed on
2010/03/26
23:03 UTC
Read the original article
Hit count: 376
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?
© Stack Overflow or respective owner