From 161a19e54717a837918519c0e29ad5f3c2590200 Mon Sep 17 00:00:00 2001
From: Yacoub Hossain <yacoub.hossain@autodesk.com>
Date: Sat, 23 Nov 2019 19:12:36 +0000
Subject: CPackNuGet: Fix handling of version specs with '['

Build a string directly to avoid depending on CMake lists which do
not handle square brackets in values very well.

Fixes: #20010
---
 Modules/Internal/CPack/CPackNuGet.cmake | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake
index b46a7b1..1f4bcfd 100644
--- a/Modules/Internal/CPack/CPackNuGet.cmake
+++ b/Modules/Internal/CPack/CPackNuGet.cmake
@@ -239,20 +239,13 @@ function(_cpack_nuget_render_spec)
 
         if(_ver)
             _cpack_nuget_debug("  got `${_dep}` dependency version ${_ver}")
-            list(APPEND _collected_deps "<dependency id=\"${_dep}\" version=\"${_ver}\" />")
+            string(CONCAT _collected_deps "${_collected_deps}" "            <dependency id=\"${_dep}\" version=\"${_ver}\" />\n")
         endif()
     endforeach()
 
     # Render deps into the variable
     if(_collected_deps)
-        set(_CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n")
-        foreach(_line IN LISTS _collected_deps)
-            string(
-                APPEND _CPACK_NUGET_DEPENDENCIES_TAG
-                "            ${_line}\n"
-              )
-        endforeach()
-        string(APPEND _CPACK_NUGET_DEPENDENCIES_TAG "        </dependencies>")
+        string(CONCAT _CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n" "${_collected_deps}" "        </dependencies>")
     endif()
 
     # Render the spec file
-- 
cgit v0.12