Building programmatically a project

后端 未结 3 1976
心在旅途
心在旅途 2021-01-04 04:02

I need to build a project programmatically for a .csproj I am creating on the fly. While searching Google I found the classes and API provided by the MS for the MSBuild Engi

3条回答
  •  走了就别回头了
    2021-01-04 04:45

    If you just want to build a project or solution, without elaborate parameters, you can do it more simply. Pseudocode:

    using namespace Microsoft.Build.Evaluation;
    
    var p = Project.Load("path to project");
    p.SetGlobalProperty("Configuration", "Release");
    p.Build(...);
    

    That's it! BuildParameters and so forth are for quite advanced scenarios. Visual Studio itself uses them.

    Dan (msbuild dev)

提交回复
热议问题