diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h index 15624fa8b1..6da291682c 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h @@ -25,6 +25,14 @@ #pragma once +inline String msBuildEscape (String str) +{ + // see https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-special-characters?view=vs-2019 + for (const auto& special : { "%", "$", "@", "'", ";", "?", "\""}) + str = str.replace (special, "%" + String::toHexString (*special)); + + return str; +} //============================================================================== class MSVCProjectExporterBase : public ProjectExporter @@ -502,7 +510,7 @@ public: { auto* targetName = props->createNewChildElement ("TargetName"); setConditionAttribute (*targetName, config); - targetName->addTextElement (config.getOutputFilename ("", false, type == UnityPlugIn)); + targetName->addTextElement (msBuildEscape (config.getOutputFilename ("", false, type == UnityPlugIn))); } { @@ -597,7 +605,7 @@ public: auto externalLibraries = getExternalLibraries (config, getOwner().getExternalLibrariesString()); auto additionalDependencies = type != SharedCodeTarget && externalLibraries.isNotEmpty() - ? getOwner().replacePreprocessorTokens (config, externalLibraries).trim() + ";%(AdditionalDependencies)" + ? msBuildEscape (getOwner().replacePreprocessorTokens (config, externalLibraries).trim()) + ";%(AdditionalDependencies)" : String(); auto librarySearchPaths = config.getLibrarySearchPaths();