Automatically create after save for Visual Studio 2015?

When using Visual Studio, I would like it to constantly build my projects. That is, after each save, start the assembly. I tend to work on large (35+ design) solutions, therefore, having everything relevant, I can save time spent on launching the application.

Roslyn gives you compiler errors as you type, but it doesnโ€™t actually start the complete build process, which means that you still need to tell VS about the failure and wait for it to complete before debugging or running the tests.

The Redgate .NET Demon used to create such a background compilation, and it was really useful, but it was discontinued because "Visual Studio 2015 will introduce Microsoft the new Roslyn compiler, with improvements that we think make .NET Demon redundant. "

Is there an option or extension for Visual Studio 2015 to automatically start the build after saving the file or changing the project in the IDE?

+5
source share
3 answers

There is an example extension for Visual Commander that runs Cppcheck in a saved file . You can replace Cppcheck with DTE.ExecuteCommand ("Build.BuildSolution");

+2
source

I started developing a new open source extension called BuildOnSave, and it does just that: it creates the current solution or startup project when the file is saved.

It is available in the Visual Studio Extension Gallery: https://visualstudiogallery.msdn.microsoft.com/2b31b977-ffc9-4066-83e8-c5596786acd0

Maybe you can try. I would really appreciate feedback.

+6
source

Based on Sergey Vlasov, answer, the version of the Visual Commander extension has been changed here;

using EnvDTE; using EnvDTE80; public class E : VisualCommanderExt.IExtension { private EnvDTE80.DTE2 DTE; private EnvDTE.Events events; private EnvDTE.DocumentEvents documentEvents; private EnvDTE.BuildEvents buildEvents; public void SetSite(EnvDTE80.DTE2 DTE_, Microsoft.VisualStudio.Shell.Package package) { DTE = DTE_; events = DTE.Events; documentEvents = events.DocumentEvents; buildEvents = events.BuildEvents; buildEvents.OnBuildProjConfigDone += OnBuildProjectDone; documentEvents.DocumentSaved += OnDocumentSaved; } public void Close() { documentEvents.DocumentSaved -= OnDocumentSaved; buildEvents.OnBuildProjConfigDone -= OnBuildProjectDone; } private void OnDocumentSaved(EnvDTE.Document doc) { if(doc.Language == "CSharp") { var sb = DTE.Solution.SolutionBuild; sb.Build(); } } private void OnBuildProjectDone(string project, string projectConfig, string platform, string solutionConfig, bool success) { //OutputString("Project " + project + " " + (success ? "build" : "failed to build")); } private void OutputString(string line) { GetOutputPane().OutputString(line + System.Environment.NewLine); } private EnvDTE.OutputWindowPane GetOutputPane() { string cppcheckPaneName = "VCmd"; foreach (EnvDTE.OutputWindowPane pane in DTE.ToolWindows.OutputWindow.OutputWindowPanes) { if (pane.Name == cppcheckPaneName) return pane; } return DTE.ToolWindows.OutputWindow.OutputWindowPanes.Add(cppcheckPaneName); } } 
0
source

Source: https://habr.com/ru/post/1234110/


All Articles