diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs
index 601e2d0b7..64714afb0 100644
--- a/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs
+++ b/Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs
@@ -462,6 +462,15 @@ internal static class Filters
";
}
}
+
+ public static class TargetElement
+ {
+ public static string CustomTarget =
+@"
+ [targetElement.CustomTasks]
+
+";
+ }
}
}
}
diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.cs
index 4c1cce30b..62d405bce 100644
--- a/Sharpmake.Generators/VisualStudio/Vcxproj.cs
+++ b/Sharpmake.Generators/VisualStudio/Vcxproj.cs
@@ -676,6 +676,15 @@ private void GenerateImpl(GenerationContext context, IList generatedFile
}
fileGenerator.Write(Template.Project.ProjectTargetsEnd);
+ foreach (var element in context.Project.CustomTargets)
+ {
+ using (fileGenerator.Declare("project", context.Project))
+ using (fileGenerator.Declare("targetElement", element))
+ {
+ fileGenerator.Write(Template.TargetElement.CustomTarget);
+ }
+ }
+
// in case we are using fast build we do not want to write most dependencies
// in the vcxproj because they are handled internally in the bff.
// Nevertheless, non-fastbuild dependencies (such as C# projects) must be written.
diff --git a/Sharpmake/Project.cs b/Sharpmake/Project.cs
index a4ca9d2be..ccbe11e47 100644
--- a/Sharpmake/Project.cs
+++ b/Sharpmake/Project.cs
@@ -223,8 +223,27 @@ internal void Resolve(string sourceRootPath, Resolver resolver)
public XResourcesImgContainer XResourcesImg = new XResourcesImgContainer();
+ [Resolver.Resolvable]
+ public class CustomTargetElement
+ {
+ public string Name = "";
+ public string TargetParameters = "";
+ public string CustomTasks = "";
+
+ public CustomTargetElement()
+ { }
+
+ public CustomTargetElement(string name, string targetParameters, string customTasks)
+ {
+ Name = name;
+ TargetParameters = targetParameters;
+ CustomTasks = customTasks;
+ }
+ }
+
public Strings CustomPropsFiles = new Strings(); // vs2010+ .props files
public Strings CustomTargetsFiles = new Strings(); // vs2010+ .targets files
+ public List CustomTargets = new List();
public Strings LibraryPathsExcludeFromWarningRegex = new Strings(); // Library paths where we want to ignore the path doesn't exist warning
public Strings IncludePathsExcludeFromWarningRegex = new Strings(); // Include paths where we want to ignore the path doesn't exist warning
@@ -2160,7 +2179,7 @@ public static void InitAspNetProject(this CSharpProject aspNetProject)
aspNetProject.NoneExtensions.Add(".pubxml");
- aspNetProject.CustomTargets.Add(new CSharpProject.CustomTargetElement()
+ aspNetProject.CustomTargets.Add(new Project.CustomTargetElement()
{
Name = "MvcBuildViews",
TargetParameters = @"AfterTargets=""AfterBuild"" Condition=""'$(MvcBuildViews)' == 'true'""",
@@ -2311,7 +2330,6 @@ public class CSharpProject : Project
public List ComReferences = new List();
public List PreImportProjects = new List();
public List ImportProjects = new List();
- public List CustomTargets = new List();
public List UsingTasks = new List();
public bool? WcfAutoStart; // Wcf Auto-Start service when debugging
@@ -2336,24 +2354,6 @@ public class CSharpProject : Project
///
public bool GenerateDocumentationFile = false;
- [Resolver.Resolvable]
- public class CustomTargetElement
- {
- public string Name;
- public string TargetParameters;
- public string CustomTasks;
-
- public CustomTargetElement()
- { }
-
- public CustomTargetElement(string name, string targetParameters, string customTasks)
- {
- Name = name;
- TargetParameters = targetParameters;
- CustomTasks = customTasks;
- }
- }
-
[Resolver.Resolvable]
public class UsingTask
{