Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sharpmake.Generators/VisualStudio/Vcxproj.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ internal static class Filters
";
}
}

public static class TargetElement
{
public static string CustomTarget =
@" <Target Name=""[targetElement.Name]"" [targetElement.TargetParameters]>
[targetElement.CustomTasks]
</Target>
";
}
}
}
}
9 changes: 9 additions & 0 deletions Sharpmake.Generators/VisualStudio/Vcxproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,15 @@ private void GenerateImpl(GenerationContext context, IList<string> 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.
Expand Down
40 changes: 20 additions & 20 deletions Sharpmake/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CustomTargetElement> CustomTargets = new List<CustomTargetElement>();

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
Expand Down Expand Up @@ -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'""",
Expand Down Expand Up @@ -2311,7 +2330,6 @@ public class CSharpProject : Project
public List<ComReference> ComReferences = new List<ComReference>();
public List<ImportProject> PreImportProjects = new List<ImportProject>();
public List<ImportProject> ImportProjects = new List<ImportProject>();
public List<CustomTargetElement> CustomTargets = new List<CustomTargetElement>();
public List<UsingTask> UsingTasks = new List<UsingTask>();

public bool? WcfAutoStart; // Wcf Auto-Start service when debugging
Expand All @@ -2336,24 +2354,6 @@ public class CSharpProject : Project
/// </summary>
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
{
Expand Down