0

I have solution with some C# project in visual studio. In another project user can show all projects in first solution. User select some project to build. also select between Release/Debug and x64/x86/any.

I can build one project with this code

Microsoft.build.Evaluation.project p = new Microsoft.build.Evaluation.project(project_path);
p.Build();

But I don't know how to build project with selected Release/Debug and x64/x86/any.

How can I change build destination directory?

1 Answer 1

1
Microsoft.Build.Evaluation.Project p = new Microsoft.Build.Evaluation.Project("path");
p.SetGlobalProperty("Configuration", "Release");
p.Build();

Should let you change the configuration used to build your project. Substitute "Configuration" for "Platform" if you wish to alter that.

Sign up to request clarification or add additional context in comments.

5 Comments

how to select x64/x86 ?
Have not tested it, however I believe it is p.SetGlobalProperty("Platform", "x86");
I'm not 100% sure, but you may not be able to call SetGlobalProperty more than once on the Project object. Have you tried modifying the GlobalProperties dictionary of the project object, or at least inspecting it in the debugger. (e.g. p.GlobalProperties.Add("Configuration", "Release"); p.GlobalProperties.Add("Platform", "Any CPU");) Also, you need to make sure that the build configuration and platform are actually defined for the project in question
How can I change build destination directory?
This is usually set in the project file configuration. Is there any reason you need to do it programmatically? Also, if my answer solved your problem, could you please mark it as "answered".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.