@@ -58,7 +58,6 @@ private GenerateFilter(Package package)
58
58
if ( commandService != null )
59
59
{
60
60
var menuCommandID = new CommandID ( CommandSet , CommandId ) ;
61
- //var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
62
61
var menuItem = new OleMenuCommand ( this . MenuItemCallback , menuCommandID ) ;
63
62
menuItem . BeforeQueryStatus += OnBeforeQueryStatus ;
64
63
@@ -145,19 +144,12 @@ static private void SetAdditionalIncludeDirectories(Project project, Dictionary<
145
144
{
146
145
if ( ! filesPerItemType . ContainsKey ( "ClInclude" ) )
147
146
return ;
148
-
149
- var stringBuilder = new StringBuilder ( ) ;
150
- var hashSet = new HashSet < string > ( ) ;
147
+
148
+ var includePaths = new HashSet < string > { @"$(StlIncludeDirectories)" } ;
151
149
foreach ( var file in filesPerItemType [ "ClInclude" ] )
152
150
{
153
- var directoryName = GetRelativePathIfNeeded ( projectPath , Path . GetDirectoryName ( file ) ) ;
154
- if ( ! hashSet . Contains ( directoryName ) )
155
- {
156
- stringBuilder . Append ( directoryName + ';' ) ;
157
- hashSet . Add ( directoryName ) ;
158
- }
151
+ includePaths . Add ( GetRelativePathIfNeeded ( projectPath , Path . GetDirectoryName ( file ) ) ) ;
159
152
}
160
- stringBuilder . Append ( @"$(StlIncludeDirectories);" ) ;
161
153
162
154
var vcProject = project . Object as VCProject ;
163
155
foreach ( VCConfiguration vcConfiguration in vcProject . Configurations )
@@ -167,10 +159,19 @@ static private void SetAdditionalIncludeDirectories(Project project, Dictionary<
167
159
var compilerTool = genericTool as VCCLCompilerTool ;
168
160
if ( compilerTool != null )
169
161
{
170
- var includeDirectories = stringBuilder . ToString ( ) ;
171
- // Avoid updating AdditionalIncludeDirectories when applicable to avoid reloading the project
172
- if ( includeDirectories != compilerTool . AdditionalIncludeDirectories )
173
- compilerTool . AdditionalIncludeDirectories = includeDirectories ;
162
+ if ( compilerTool . AdditionalIncludeDirectories == null )
163
+ compilerTool . AdditionalIncludeDirectories = string . Empty ;
164
+
165
+ var sss = compilerTool . AdditionalIncludeDirectories ;
166
+ var currentAdditionalIncludeDirectories = new HashSet < string > ( compilerTool . AdditionalIncludeDirectories . Split ( new char [ ] { ';' } , StringSplitOptions . RemoveEmptyEntries ) ) ;
167
+ var pathsToAdd = new StringBuilder ( ) ;
168
+ foreach ( var includePath in includePaths )
169
+ // Avoid updating AdditionalIncludeDirectories when applicable to avoid reloading the project
170
+ if ( ! currentAdditionalIncludeDirectories . Contains ( includePath ) )
171
+ pathsToAdd . Append ( includePath + ';' ) ;
172
+
173
+ if ( pathsToAdd . Length > 0 )
174
+ compilerTool . AdditionalIncludeDirectories = pathsToAdd . ToString ( ) + compilerTool . AdditionalIncludeDirectories ;
174
175
}
175
176
}
176
177
}
@@ -387,7 +388,6 @@ private void MenuItemCallback(object sender, EventArgs e)
387
388
var projectFilename = project . FileName ;
388
389
var projectPath = Path . GetDirectoryName ( projectFilename ) ;
389
390
SetAdditionalIncludeDirectories ( project , filesPerItemType , projectPath ) ;
390
- // Check if user is prompted? (what if he made his own change and want to discard them? i.e. can use project.Saved first)
391
391
project . DTE . ExecuteCommand ( "Project.UnloadProject" ) ;
392
392
393
393
var xmlSettings = new XmlWriterSettings ( ) { Indent = true } ;
0 commit comments