I have written an AddIn for VS2003. The AddIn opens a solution, sets
the current Configuration to Release, sets all projects to
ShouldBuild, Cleans the solution, organizes the Projects by
dependencies, and then builds each Project.
If I open a Solution with 4 projects with NO dependencies between any
projects and run the AddIn, I get repeated compiles. Assuming the
projects are ordered Project1, Project2, Project3, and Project4: When
I compile Project1, it builds. When I compile Project2, it will first
compile Project1 (which is Up-To-Date so it goes fast) and then
Project2 compiles. Project3 causes an attempted compile of 1 and then
2 before 3 compiles.
I can post some more code if need be and I have a standalone AddIn
that demonstrates this issue but let me give a skeleton and see if
anyone has some ideas. Note that Wait(true) performs a PeekMessage
loop until OnBuildDone is called and Wait(false) performs a
PeekMessage loop until ProjectBuildFinished is called but more
importantly also waits for OnBuildProjConfigDone to be called where
the 1st param matches m_csCurrentProject.
CComPtr<EnvDTE::_Solution> pDispSolution;
VERIFY_OK(m_pDTE->get_Solution(&pDispSolution));
CComBSTR bszWorkspacePathName =
"C:\\CODE\\T1\\T1TEST\\T1TEST.SLN";
VERIFY_OK(pDispSolution->Open(bszWorkspacePathName));
{
// set the active configuration to Release
CComPtr<EnvDTE::Commands> pCommands;
VERIFY_OK(m_pDTE->get_Commands(&pCommands));
CComBSTR bszGUID = "{5EFC7975-14BC-11CF-9B2B-00AA00573819}";
long lID = 684;
CComVariant Vari("Release");
CComVariant CustomOut;
VERIFY_OK(pCommands->Raise(bszGUID, 684, &Vari, &CustomOut));
}
CComPtr<EnvDTE::SolutionBuild> pSolutionBuild;
VERIFY_OK(pDispSolution->get_SolutionBuild(&pSolutionBuild));
... // use project dependencies to fill in m_projectCompileOrder
... // which is of type CAtlList<CComPtr<EnvDTE::Project>
for (POSITION pos = m_projectCompileOrder.GetHeadPosition(); pos
!= NULL;)
{
CComPtr<EnvDTE::Project> pGenProject =
m_projectCompileOrder.GetNext(pos);
CComPtr<IDispatch> pDispatch;
VERIFY_OK(pGenProject->get_Object(&pDispatch));
m_pVCProject = pDispatch;
CComBSTR bszProjectFileName;
VERIFY_OK(m_pVCProject->get_ProjectFile(&bszProjectFileName));
m_csCurrentProject = bszProjectFileName;
m_csCurrentProject.MakeUpper();
CComPtr<IDispatch> pDispConfigs;
VERIFY_OK(m_pVCProject->get_Configurations(&pDispConfigs));
CComQIPtr<IVCCollection> pVCConfigurations(pDispConfigs);
CComPtr<EnvDTE::SolutionConfiguration> pSolutionConfiguration;
VERIFY_OK(pSolutionBuild->get_ActiveConfiguration(&pSolutionConfiguration));
CComPtr<EnvDTE::SolutionContexts> pSolutionContexts;
VERIFY_OK(pSolutionConfiguration->get_SolutionContexts(&pSolutionContexts));
CComBSTR projectUniqueName;
pGenProject->get_UniqueName(&projectUniqueName);
CComPtr<EnvDTE::SolutionContext> pSolutionContext;
pSolutionContexts->Item(CComVariant(projectUniqueName),
&pSolutionContext);
CComBSTR bstrConfigurationName;
VERIFY_OK(pSolutionContext->get_ConfigurationName(&bstrConfigurationName));
CComBSTR bstrPlatformName;
VERIFY_OK(pSolutionContext->get_PlatformName(&bstrPlatformName));
CString configurationCombinedName =
CString(bstrConfigurationName) + "|" + CString(bstrPlatformName);
CComBSTR bstrConfigurationCombinedName =
configurationCombinedName;
CComPtr<IDispatch> pDispConfig;
VERIFY_OK(pVCConfigurations->Item(CComVariant(bstrConfigurationCombinedName),
&pDispConfig));
m_pConfig = pDispConfig;
CComVariant VarDisp = m_pConfig;
if (m_pVCProjectEngineEvents)
{
AtlTrace("Unadvise VCProjectEngineEvents SHOULD NOT HAVE
REACHED HERE!\r\n");
VERIFY_OK(m_VCProjectEngineEventsSink.DispEventUnadvise((IUnknown*)m_pVCProjectEngineEvents.p));
m_pVCProjectEngineEvents = NULL;
}
CComPtr<IDispatch> pDispProjEngine;
VERIFY_OK(m_pVCProject->get_VCProjectEngine(&pDispProjEngine));
CComQIPtr<VCProjectEngine> pEngine;
pEngine = pDispProjEngine;
CComPtr<IDispatch> pDispProjEvents;
VERIFY_OK(pEngine->get_Events(&pDispProjEvents));
m_pVCProjectEngineEvents = pDispProjEvents;
if (m_pVCProjectEngineEvents)
{
VERIFY_OK(m_VCProjectEngineEventsSink.DispEventAdvise((IUnknown*)m_pVCProjectEngineEvents.p));
}
m_bInBuild = true;
m_bInConfigBuild = true;
VERIFY_OK(m_pConfig->Build());
this->Wait(false);
TRACE("After Wait for Build\r\n");
if (m_pVCProjectEngineEvents)
{
TRACE("Unadvise VCProjectEngineEvents\r\n");
VERIFY_OK(m_VCProjectEngineEventsSink.DispEventUnadvise((IUnknown*)m_pVCProjectEngineEvents.p));
m_pVCProjectEngineEvents = NULL;
}
pDispProjEvents = NULL;
pEngine = (IUnknown *)NULL;
pDispProjEngine = NULL;
m_pConfig = (IUnknown *)NULL;
pDispConfig = NULL;
pVCConfigurations = (IUnknown *)NULL;
pSolutionContext = NULL;
pSolutionContexts = NULL;
pSolutionConfiguration = NULL;
pDispConfigs = NULL;
m_pVCProject = (IUnknown *)NULL;
pDispatch = NULL;
pGenProject = NULL;
}
this->Wait(true);
TRACE("After Wait for OnBuildDone\r\n");
... // code continues closing the solution and Quitting IDE
Jim Butts - 27 Jul 2004 05:22 GMT
Can anyone help me with this? It seems like a bug in the IDE. I hope
its fixed for VS 2005.
Steve McLellan - 27 Jul 2004 13:18 GMT
If you mean that dependencies don't seem to be working or are slow, try the
link below. I've not used it, so can't vouch for its safety / usefulness.
http://www.workspacewhiz.com/FastSolutionBuild/FastSolutionBuildReadme.html
> Can anyone help me with this? It seems like a bug in the IDE. I hope
> its fixed for VS 2005.