How do I build a C# solution programmatically?
I should be able to pass the path of a solution and get the output messages (or just build the solution). How do I ach
If you need to trigger the build from Visual Studio extension code, you must consider the limitations imposed by IVsBuildManagerAccessor interface - see the General Notes, including new IVsBuildManagerAccessor.docx from Managed Package Framework for Projects. Its fork is also available at GitHub.
In Visual Studio 2010 with MSBuild 4.0, there are new interactions between the Solution Build Manager and MSBuild which impact project systems utilizing these services. MSBuild 4.0 contains a new component called the Build Manager (not to be confused with the Solution Build Manager which is a VS component) which controls the submission of build requests. This became necessary as Visual Studio 2010 now allows parallel builds to occur (notably native projects) and access to shared resources such as the CPU needed to be mediated. For project systems which previously simply called Project.Build() to invoke a build several changes must be made. The project system now must:
- Ask for the SVsBuildManagerAccessor service using the IServiceProvider interface. This should be done soon after the project system is loaded, well before any builds might occur.
- Notify the system if you need the UI thread
- Notify the system if you are doing a design-time build.
- Register its loggers using the Build Manager Accessor.
- Submit build requests directly to the MSBuild Build Manager, rather than invoking a method on the Project.