How do I save a project via API in silent mode
My eighth How do I is up.
Scenario
When we modify a project file programmatically and we save it, Visual Studio monitors file changes and when a change is detected the following dialog appears:

Let's say that we control the change of the project file and want to avoid that dialog. The focus of this How do I tackles this scenario.
Interfaces and classes needed
Code snippet
public static void SaveProjectSilent(IServiceProvider serviceProvider, IVsHierarchy project)
{
IVsSolution solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
ErrorHandler.ThrowOnFailure(
solution.SaveSolutionElement(
(uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave,
project,
(uint)VSConstants.VSCOOKIE_NIL));
}
Assemblies needed
- Microsoft.VisualStudio.Shell.Interop
- Microsoft.VisualStudio.Shell.9.0
Stay tuned,
Pablo