what's an effective way to build a csproj file in code?
- by jcollum
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?