diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs
index 86c33615b..8df11fdce 100644
--- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs
+++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatform.Vcxproj.Template.cs
@@ -79,7 +79,7 @@ public sealed partial class AndroidPlatform
[options.UsePrecompiledHeader]
[options.WarningLevel]
[options.Optimization]
- [options.PreprocessorDefinitions];%(PreprocessorDefinitions)
+ [EscapeXML:options.PreprocessorDefinitions];%(PreprocessorDefinitions)
[options.AdditionalIncludeDirectories];%(AdditionalIncludeDirectories)
[options.DebugInformationFormat]
[options.TreatWarningAsError]
diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatformAgde.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatformAgde.Vcxproj.Template.cs
index 7300a4a2a..81e540b2f 100644
--- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatformAgde.Vcxproj.Template.cs
+++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Android/AndroidPlatformAgde.Vcxproj.Template.cs
@@ -79,7 +79,7 @@ public sealed partial class AndroidAgdePlatform
[options.UsePrecompiledHeader]
[options.WarningLevel]
[options.Optimization]
- [options.PreprocessorDefinitions];%(PreprocessorDefinitions)
+ [EscapeXML:options.PreprocessorDefinitions];%(PreprocessorDefinitions)
[options.AdditionalIncludeDirectories];%(AdditionalIncludeDirectories)
[options.ClangDebugInformationFormat]
[options.LimitDebugInfo]
diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs
index d85b8bd8e..b97c12144 100644
--- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs
+++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BaseMicrosoftPlatform.Vcxproj.Template.cs
@@ -7,7 +7,7 @@ public abstract partial class BaseMicrosoftPlatform
{
private const string _projectConfigurationsMasmTemplate =
@"
- [options.PreprocessorDefinitions];%(PreprocessorDefinitions);$(PreprocessorDefinitions)
+ [EscapeXML:options.PreprocessorDefinitions];%(PreprocessorDefinitions);$(PreprocessorDefinitions)
[options.AdditionalAssemblyIncludeDirectories]
";
diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs
index 6d25d52b7..dcb734b2e 100644
--- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs
+++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs
@@ -14,7 +14,7 @@ public abstract partial class BasePlatform
[options.ExternalWarningLevel]
[options.ExternalTemplatesDiagnostics]
[options.Optimization]
- [options.PreprocessorDefinitions];%(PreprocessorDefinitions);$(PreprocessorDefinitions)
+ [EscapeXML:options.PreprocessorDefinitions];%(PreprocessorDefinitions);$(PreprocessorDefinitions)
[options.AdditionalIncludeDirectories]
[options.AdditionalUsingDirectories]
[options.DebugInformationFormat]
@@ -267,7 +267,7 @@ public abstract partial class BasePlatform
del ""[options.OutputDirectory]\[conf.TargetFileFullName].lib"" >NUL 2>NUL
del ""[options.OutputDirectory]\[conf.TargetFileFullName].pdb"" >NUL 2>NUL
[options.OutputFile]
- [options.PreprocessorDefinitions]
+ [EscapeXML:options.PreprocessorDefinitions]
[options.AdditionalIncludeDirectories]
[options.ForcedIncludeFiles]
[options.AdditionalOptions]
@@ -282,7 +282,7 @@ public abstract partial class BasePlatform
[conf.CustomBuildSettings.RebuildCommand]
[conf.CustomBuildSettings.CleanCommand]
[conf.CustomBuildSettings.OutputFile]
- [options.PreprocessorDefinitions]
+ [EscapeXML:options.PreprocessorDefinitions]
[options.AdditionalIncludeDirectories]
[options.ForcedIncludeFiles]
[options.AdditionalOptions]
diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs
index 16b465fa0..6d0f3c157 100644
--- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs
+++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Linux/LinuxPlatform.Vcxproj.Template.cs
@@ -13,7 +13,7 @@ public sealed partial class LinuxPlatform
private const string _projectConfigurationsCompileTemplate =
@"
[options.UsePrecompiledHeader]
- [options.PreprocessorDefinitions];%(PreprocessorDefinitions);
+ [EscapeXML:options.PreprocessorDefinitions];%(PreprocessorDefinitions);
[options.ForcedIncludeFiles]
[options.DebugInformationFormat]
[options.Warnings]
diff --git a/Sharpmake.UnitTests/ResolverTest.cs b/Sharpmake.UnitTests/ResolverTest.cs
index 830145772..a3e59ce87 100644
--- a/Sharpmake.UnitTests/ResolverTest.cs
+++ b/Sharpmake.UnitTests/ResolverTest.cs
@@ -286,6 +286,21 @@ public void CanResolveStringsToLower()
Assert.That(obj.Value2, Is.EqualTo("propertyclass"));
Assert.That(obj.Value3, Is.EqualTo("propertyclass"));
}
+
+ [Test]
+ public void CanResolveStringsEscape()
+ {
+ var obj = new PropertyClass();
+ obj.Value1 = "";
+
+ string someTemplate = @"[EscapeXML:obj.Value1]";
+
+ var resolver = new Resolver();
+ resolver.SetParameter("obj", obj);
+ string result = resolver.Resolve(someTemplate);
+
+ Assert.AreEqual("<stuff>", result);
+ }
}
}
diff --git a/Sharpmake/Resolver.cs b/Sharpmake/Resolver.cs
index b15c4781e..8977a4b54 100644
--- a/Sharpmake/Resolver.cs
+++ b/Sharpmake/Resolver.cs
@@ -594,7 +594,8 @@ public NotFoundException(string message, IEnumerable arguments = null)
private enum PropertyModifier
{
None,
- Lower
+ Lower,
+ EscapeXML
}
private static readonly char[] s_modifierNameSplitter = new[] { ':' };
@@ -626,6 +627,8 @@ private static string ApplyModifier(PropertyModifier modifier, string input)
return input;
case PropertyModifier.Lower:
return input.ToLowerInvariant();
+ case PropertyModifier.EscapeXML:
+ return Util.EscapeXml(input);
default:
throw new NotSupportedException($"Don't know how to apply modifier {modifier} to '{input}'");
}