diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.cs
index d014602d1..b31d65cf2 100644
--- a/Sharpmake.Generators/VisualStudio/Vcxproj.cs
+++ b/Sharpmake.Generators/VisualStudio/Vcxproj.cs
@@ -1249,7 +1249,7 @@ private void GenerateFilesSection(IVcxprojGenerationContext context, IFileGenera
bool addFile = false;
foreach (Project.Configuration conf in context.ProjectConfigurations)
{
- if (conf.ResolvedSourceFilesBuildExclude.Contains(projectFile.FileName) == false)
+ if (conf.ResolvedSourceFilesExclude.Contains(projectFile.FileName) == false)
{
addFile = true;
break;
diff --git a/Sharpmake/Project.Configuration.cs b/Sharpmake/Project.Configuration.cs
index f7baa5f98..132d8b43a 100644
--- a/Sharpmake/Project.Configuration.cs
+++ b/Sharpmake/Project.Configuration.cs
@@ -303,6 +303,14 @@ public OutputType Output
public Strings SourceFilesFiltersRegex = new Strings();
+ ///
+ /// Excluded file from project for this configuration
+ ///
+ public Strings SourceFilesExclude = new Strings();
+
+ public Strings SourceFilesExcludeRegex = new Strings();
+
+
///
/// Sources file that match this regex will be compiled as C Files
///
@@ -1045,6 +1053,8 @@ public void GeneratorSetGeneratedInformation(string executableExtension, string
public Strings ResolvedSourceFilesBuildExclude = new Strings();
+ public Strings ResolvedSourceFilesExclude = new Strings();
+
public Strings ResolvedSourceFilesBlobExclude = new Strings();
public Strings ResolvedSourceFilesWithCompileAsCOption = new Strings();
diff --git a/Sharpmake/Project.cs b/Sharpmake/Project.cs
index f66a108fa..a0bfe8d9e 100644
--- a/Sharpmake/Project.cs
+++ b/Sharpmake/Project.cs
@@ -814,8 +814,23 @@ internal virtual void ResolveSourceFiles(Builder builder)
if (conf.IsFastBuild && conf.FastBuildBlobbed)
fastBuildBlobs = true;
+ var confSourceFilesExcludeRegex = RegexCache.GetCachedRegexes(conf.SourceFilesExcludeRegex);
+
+ // Remove file that match conf.SourceFilesExcludeRegex
+ if (AddMatchFiles(RootPath, Util.PathGetRelative(RootPath, SourceFiles), SourceFiles, ref conf.SourceFilesExclude, confSourceFilesExcludeRegex))
+ System.Diagnostics.Debugger.Break();
+ if (AddMatchFiles(RootPath, Util.PathGetRelative(RootPath, ResourceFiles), ResourceFiles, ref conf.SourceFilesExclude, confSourceFilesExcludeRegex))
+ System.Diagnostics.Debugger.Break();
+ if (AddMatchFiles(RootPath, Util.PathGetRelative(RootPath, NatvisFiles), NatvisFiles, ref conf.SourceFilesExclude, confSourceFilesExcludeRegex))
+ System.Diagnostics.Debugger.Break();
+
conf.ResolvedSourceFilesBuildExclude.AddRange(SourceFilesExclude);
+ //Add SourceFilesExclude also to ResolvedSourceFilesBuildExclude in case we end up needing file for
+ //another configuration that way it gets added but excluded from build in this config
+ conf.ResolvedSourceFilesBuildExclude.AddRange(conf.SourceFilesExclude);
+ conf.ResolvedSourceFilesExclude.AddRange(conf.SourceFilesExclude);
+
// add SourceFilesBuildExclude from the project
if (DebugBreaks.ShouldBreakOnSourcePath(DebugBreaks.Context.Resolving, ResolvedSourceFilesBuildExclude))
System.Diagnostics.Debugger.Break();
@@ -939,6 +954,7 @@ internal virtual void ResolveSourceFiles(Builder builder)
conf.ResolvedSourceFilesBuildExclude.Add(sourceFile);
}
Util.ResolvePath(SourceRootPath, ref conf.ResolvedSourceFilesBuildExclude);
+ Util.ResolvePath(SourceRootPath, ref conf.ResolvedSourceFilesExclude);
}
}
diff --git a/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj b/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj
index 149a398d0..c47bb6b88 100644
--- a/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj
+++ b/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj
@@ -486,14 +486,44 @@
true
true
+
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+
true
true
+
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+
true
true
+
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+
diff --git a/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj.filters b/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj.filters
index 3f8cace2c..c875a4b0f 100644
--- a/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj.filters
+++ b/samples/QTFileCustomBuild/reference/projects/qtfilecustombuild_vs2017_win64.vcxproj.filters
@@ -11,12 +11,30 @@
projects\obj\win64\qt\debug
+
+ projects\obj\win64\qt\debug
+
+
+ projects\obj\win64\qt\debug
+
projects\obj\win64\qt\release
+
+ projects\obj\win64\qt\release
+
+
+ projects\obj\win64\qt\release
+
projects\obj\win64\qt\retail
+
+ projects\obj\win64\qt\retail
+
+
+ projects\obj\win64\qt\retail
+