Last active
November 10, 2016 20:57
-
-
Save 3F/a7f8eeb59ade9139d4da4862e03ee225 to your computer and use it in GitHub Desktop.
Script to reload projects in solution of Visual Studio IDE after adding git submodules. For https://github.com/3F/LunaRoad via vsSBE: https://visualstudiogallery.msdn.microsoft.com/0d1dbfd7-ed8a-40af-ae39-281bfeca2334/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#[($(ProjectDir:Conari) == "*Undefined*" && ( $(BuildingInsideVisualStudio) || $(VSIDE) || $(DevEnvDir) != "*Undefined*") ) { | |
using System; | |
using Microsoft.VisualStudio; | |
using Microsoft.VisualStudio.Shell.Interop; | |
using ICommand = net.r_eg.vsSBE.Actions.ICommand; | |
using ISolutionEvent = net.r_eg.vsSBE.Events.ISolutionEvent; | |
namespace vsSolutionBuildEvent | |
{ | |
public class CSharpMode | |
{ | |
public static int Init(ICommand cmd, ISolutionEvent evt) | |
{ | |
System.Diagnostics.Process.Start(@"$(SolutionDir)submodules.bat").WaitForExit(); | |
object service = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution)); | |
IVsSolution sln = (IVsSolution)service; | |
IVsSolution4 sln4 = (IVsSolution4)service; | |
IEnumHierarchies projects; | |
Guid gtype = Guid.Empty; | |
if(ErrorHandler.Failed(sln.GetProjectEnum((int)__VSENUMPROJFLAGS.EPF_UNLOADEDINSOLUTION /*EPF_ALLPROJECTS*/, ref gtype, out projects))) { | |
return 0; | |
} | |
var phr = new IVsHierarchy[1]; | |
uint count; | |
while((projects.Next((uint)phr.Length, phr, out count) == VSConstants.S_OK) && (count > 0)) | |
{ | |
Guid pGuid; | |
if(ErrorHandler.Failed(sln.GetGuidOfProject(phr[0], out pGuid))) { | |
continue; | |
} | |
sln4.EnsureProjectIsLoaded(ref pGuid, (uint)__VSBSLFLAGS.VSBSLFLAGS_None); | |
} | |
return 0; | |
} | |
} | |
} | |
//}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment