We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
MSBuild /bl flag for Binary Logging
MSBuild has a command line flag to activate the output of a Binary Log that can replay builds to gather diagnostics on builds.

I would be really useful to add this utility to the MSBuild helper.

[MSBuild Binary Log Docs](https://github.com/Microsoft/msbuild/blob/master/documentation/wiki/Binary-Log.md)



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conans/client/build/msbuild.py`
Content:
```
1 import copy
2 import re
3 
4 from conans import tools
5 from conans.client.build.visual_environment import (VisualStudioBuildEnvironment,
6                                                     vs_build_type_flags, vs_std_cpp)
7 from conans.client.tools.oss import cpu_count
8 from conans.client.tools.win import vcvars_command
9 from conans.errors import ConanException
10 from conans.util.env_reader import get_env
11 from conans.util.files import tmp_file
12 from conans.model.conan_file import ConanFile
13 
14 
15 class MSBuild(object):
16 
17     def __init__(self, conanfile):
18         if isinstance(conanfile, ConanFile):
19             self._conanfile = conanfile
20             self._settings = self._conanfile.settings
21             self._output = self._conanfile.output
22             self.build_env = VisualStudioBuildEnvironment(self._conanfile)
23         else:  # backwards compatible with build_sln_command
24             self._settings = conanfile
25             self.build_env = None
26 
27     def build(self, project_file, targets=None, upgrade_project=True, build_type=None, arch=None,
28               parallel=True, force_vcvars=False, toolset=None, platforms=None, use_env=True,
29               vcvars_ver=None, winsdk_version=None, properties=None):
30 
31         self.build_env.parallel = parallel
32 
33         with tools.environment_append(self.build_env.vars):
34             # Path for custom properties file
35             props_file_contents = self._get_props_file_contents()
36             with tmp_file(props_file_contents) as props_file_path:
37                 vcvars = vcvars_command(self._conanfile.settings, force=force_vcvars,
38                                         vcvars_ver=vcvars_ver, winsdk_version=winsdk_version)
39                 command = self.get_command(project_file, props_file_path,
40                                            targets=targets, upgrade_project=upgrade_project,
41                                            build_type=build_type, arch=arch, parallel=parallel,
42                                            toolset=toolset, platforms=platforms,
43                                            use_env=use_env, properties=properties)
44                 command = "%s && %s" % (vcvars, command)
45                 return self._conanfile.run(command)
46 
47     def get_command(self, project_file, props_file_path=None, targets=None, upgrade_project=True,
48                     build_type=None, arch=None, parallel=True, toolset=None, platforms=None,
49                     use_env=False, properties=None):
50 
51         targets = targets or []
52         properties = properties or {}
53         command = []
54 
55         if upgrade_project and not get_env("CONAN_SKIP_VS_PROJECTS_UPGRADE", False):
56             command.append('devenv "%s" /upgrade &&' % project_file)
57         else:
58             self._output.info("Skipped sln project upgrade")
59 
60         build_type = build_type or self._settings.get_safe("build_type")
61         arch = arch or self._settings.get_safe("arch")
62         if not build_type:
63             raise ConanException("Cannot build_sln_command, build_type not defined")
64         if not arch:
65             raise ConanException("Cannot build_sln_command, arch not defined")
66 
67         command.append('msbuild "%s" /p:Configuration="%s"' % (project_file, build_type))
68         msvc_arch = {'x86': 'x86',
69                      'x86_64': 'x64',
70                      'armv7': 'ARM',
71                      'armv8': 'ARM64'}
72         if platforms:
73             msvc_arch.update(platforms)
74         msvc_arch = msvc_arch.get(str(arch))
75         try:
76             sln = tools.load(project_file)
77             pattern = re.compile(r"GlobalSection\(SolutionConfigurationPlatforms\)"
78                                  r"(.*?)EndGlobalSection", re.DOTALL)
79             solution_global = pattern.search(sln).group(1)
80             lines = solution_global.splitlines()
81             lines = [s.split("=")[0].strip() for s in lines]
82         except Exception:
83             pass
84         else:
85             config = "%s|%s" % (build_type, msvc_arch)
86             if config not in "".join(lines):
87                 self._output.warn("***** The configuration %s does not exist in this solution *****" % config)
88                 self._output.warn("Use 'platforms' argument to define your architectures")
89 
90         if use_env:
91             command.append('/p:UseEnv=true')
92 
93         if msvc_arch:
94             command.append('/p:Platform="%s"' % msvc_arch)
95 
96         if parallel:
97             command.append('/m:%s' % cpu_count())
98 
99         if targets:
100             command.append("/target:%s" % ";".join(targets))
101 
102         if toolset:
103             command.append('/p:PlatformToolset="%s"' % toolset)
104 
105         if props_file_path:
106             command.append('/p:ForceImportBeforeCppTargets="%s"' % props_file_path)
107 
108         for name, value in properties.items():
109             command.append('/p:%s="%s"' % (name, value))
110 
111         return " ".join(command)
112 
113     def _get_props_file_contents(self):
114         # how to specify runtime in command line:
115         # https://stackoverflow.com/questions/38840332/msbuild-overrides-properties-while-building-vc-project
116         runtime_library = {"MT": "MultiThreaded",
117                            "MTd": "MultiThreadedDebug",
118                            "MD": "MultiThreadedDLL",
119                            "MDd": "MultiThreadedDebugDLL"}.get(self._settings.get_safe("compiler.runtime"), "")
120 
121         if self.build_env:
122             # Take the flags from the build env, the user was able to alter them if needed
123             flags = copy.copy(self.build_env.flags)
124             flags.append(self.build_env.std)
125         else:  # To be removed when build_sln_command is deprecated
126             flags = vs_build_type_flags(self._settings)
127             flags.append(vs_std_cpp(self._settings))
128 
129         flags_str = " ".join(list(filter(None, flags))) # Removes empty and None elements
130         additional_node = "<AdditionalOptions>" \
131                           "{} %(AdditionalOptions)" \
132                           "</AdditionalOptions>".format(flags_str) if flags_str else ""
133         runtime_node = "<RuntimeLibrary>" \
134                        "{}" \
135                        "</RuntimeLibrary>".format(runtime_library) if runtime_library else ""
136         template = """<?xml version="1.0" encoding="utf-8"?>
137 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
138   <ItemDefinitionGroup>
139     <ClCompile>
140       {runtime_node}
141       {additional_node}
142     </ClCompile>
143   </ItemDefinitionGroup>
144 </Project>""".format(**{"runtime_node": runtime_node,
145                         "additional_node": additional_node})
146         return template
147
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/conans/client/build/msbuild.py b/conans/client/build/msbuild.py
--- a/conans/client/build/msbuild.py
+++ b/conans/client/build/msbuild.py
@@ -1,5 +1,6 @@
 import copy
 import re
+import subprocess
 
 from conans import tools
 from conans.client.build.visual_environment import (VisualStudioBuildEnvironment,
@@ -7,8 +8,9 @@
 from conans.client.tools.oss import cpu_count
 from conans.client.tools.win import vcvars_command
 from conans.errors import ConanException
+from conans.model.version import Version
 from conans.util.env_reader import get_env
-from conans.util.files import tmp_file
+from conans.util.files import tmp_file, decode_text
 from conans.model.conan_file import ConanFile
 
 
@@ -26,7 +28,7 @@
 
     def build(self, project_file, targets=None, upgrade_project=True, build_type=None, arch=None,
               parallel=True, force_vcvars=False, toolset=None, platforms=None, use_env=True,
-              vcvars_ver=None, winsdk_version=None, properties=None):
+              vcvars_ver=None, winsdk_version=None, properties=None, output_binary_log=None):
 
         self.build_env.parallel = parallel
 
@@ -40,13 +42,13 @@
                                            targets=targets, upgrade_project=upgrade_project,
                                            build_type=build_type, arch=arch, parallel=parallel,
                                            toolset=toolset, platforms=platforms,
-                                           use_env=use_env, properties=properties)
+                                           use_env=use_env, properties=properties, output_binary_log=output_binary_log)
                 command = "%s && %s" % (vcvars, command)
                 return self._conanfile.run(command)
 
     def get_command(self, project_file, props_file_path=None, targets=None, upgrade_project=True,
                     build_type=None, arch=None, parallel=True, toolset=None, platforms=None,
-                    use_env=False, properties=None):
+                    use_env=False, properties=None, output_binary_log=None):
 
         targets = targets or []
         properties = properties or {}
@@ -87,6 +89,15 @@
                 self._output.warn("***** The configuration %s does not exist in this solution *****" % config)
                 self._output.warn("Use 'platforms' argument to define your architectures")
 
+        if output_binary_log:
+            msbuild_version = MSBuild.get_version(self._settings)
+            if msbuild_version >= "15.3":  # http://msbuildlog.com/
+                command.append('/bl' if isinstance(output_binary_log, bool)
+                               else '/bl:"%s"' % output_binary_log)
+            else:
+                raise ConanException("MSBuild version detected (%s) does not support "
+                                     "'output_binary_log' ('/bl')" % msbuild_version)
+
         if use_env:
             command.append('/p:UseEnv=true')
 
@@ -144,3 +155,17 @@
 </Project>""".format(**{"runtime_node": runtime_node,
                         "additional_node": additional_node})
         return template
+
+    @staticmethod
+    def get_version(settings):
+        msbuild_cmd = "msbuild -version"
+        vcvars = vcvars_command(settings)
+        command = "%s && %s" % (vcvars, msbuild_cmd)
+        try:
+            out, err = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True).communicate()
+            version_line = decode_text(out).split("\n")[-1]
+            prog = re.compile("(\d+\.){2,3}\d+")
+            result = prog.match(version_line).group()
+            return Version(result)
+        except Exception as e:
+            raise ConanException("Error retrieving MSBuild version: '{}'".format(e))

{"golden_diff": "diff --git a/conans/client/build/msbuild.py b/conans/client/build/msbuild.py\n--- a/conans/client/build/msbuild.py\n+++ b/conans/client/build/msbuild.py\n@@ -1,5 +1,6 @@\n import copy\n import re\n+import subprocess\n \n from conans import tools\n from conans.client.build.visual_environment import (VisualStudioBuildEnvironment,\n@@ -7,8 +8,9 @@\n from conans.client.tools.oss import cpu_count\n from conans.client.tools.win import vcvars_command\n from conans.errors import ConanException\n+from conans.model.version import Version\n from conans.util.env_reader import get_env\n-from conans.util.files import tmp_file\n+from conans.util.files import tmp_file, decode_text\n from conans.model.conan_file import ConanFile\n \n \n@@ -26,7 +28,7 @@\n \n     def build(self, project_file, targets=None, upgrade_project=True, build_type=None, arch=None,\n               parallel=True, force_vcvars=False, toolset=None, platforms=None, use_env=True,\n-              vcvars_ver=None, winsdk_version=None, properties=None):\n+              vcvars_ver=None, winsdk_version=None, properties=None, output_binary_log=None):\n \n         self.build_env.parallel = parallel\n \n@@ -40,13 +42,13 @@\n                                            targets=targets, upgrade_project=upgrade_project,\n                                            build_type=build_type, arch=arch, parallel=parallel,\n                                            toolset=toolset, platforms=platforms,\n-                                           use_env=use_env, properties=properties)\n+                                           use_env=use_env, properties=properties, output_binary_log=output_binary_log)\n                 command = \"%s && %s\" % (vcvars, command)\n                 return self._conanfile.run(command)\n \n     def get_command(self, project_file, props_file_path=None, targets=None, upgrade_project=True,\n                     build_type=None, arch=None, parallel=True, toolset=None, platforms=None,\n-                    use_env=False, properties=None):\n+                    use_env=False, properties=None, output_binary_log=None):\n \n         targets = targets or []\n         properties = properties or {}\n@@ -87,6 +89,15 @@\n                 self._output.warn(\"***** The configuration %s does not exist in this solution *****\" % config)\n                 self._output.warn(\"Use 'platforms' argument to define your architectures\")\n \n+        if output_binary_log:\n+            msbuild_version = MSBuild.get_version(self._settings)\n+            if msbuild_version >= \"15.3\":  # http://msbuildlog.com/\n+                command.append('/bl' if isinstance(output_binary_log, bool)\n+                               else '/bl:\"%s\"' % output_binary_log)\n+            else:\n+                raise ConanException(\"MSBuild version detected (%s) does not support \"\n+                                     \"'output_binary_log' ('/bl')\" % msbuild_version)\n+\n         if use_env:\n             command.append('/p:UseEnv=true')\n \n@@ -144,3 +155,17 @@\n </Project>\"\"\".format(**{\"runtime_node\": runtime_node,\n                         \"additional_node\": additional_node})\n         return template\n+\n+    @staticmethod\n+    def get_version(settings):\n+        msbuild_cmd = \"msbuild -version\"\n+        vcvars = vcvars_command(settings)\n+        command = \"%s && %s\" % (vcvars, msbuild_cmd)\n+        try:\n+            out, err = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True).communicate()\n+            version_line = decode_text(out).split(\"\\n\")[-1]\n+            prog = re.compile(\"(\\d+\\.){2,3}\\d+\")\n+            result = prog.match(version_line).group()\n+            return Version(result)\n+        except Exception as e:\n+            raise ConanException(\"Error retrieving MSBuild version: '{}'\".format(e))\n", "issue": "MSBuild /bl flag for Binary Logging\nMSBuild has a command line flag to activate the output of a Binary Log that can replay builds to gather diagnostics on builds.\r\n\r\nI would be really useful to add this utility to the MSBuild helper.\r\n\r\n[MSBuild Binary Log Docs](https://github.com/Microsoft/msbuild/blob/master/documentation/wiki/Binary-Log.md)\r\n\r\n\n", "before_files": [{"content": "import copy\nimport re\n\nfrom conans import tools\nfrom conans.client.build.visual_environment import (VisualStudioBuildEnvironment,\n                                                    vs_build_type_flags, vs_std_cpp)\nfrom conans.client.tools.oss import cpu_count\nfrom conans.client.tools.win import vcvars_command\nfrom conans.errors import ConanException\nfrom conans.util.env_reader import get_env\nfrom conans.util.files import tmp_file\nfrom conans.model.conan_file import ConanFile\n\n\nclass MSBuild(object):\n\n    def __init__(self, conanfile):\n        if isinstance(conanfile, ConanFile):\n            self._conanfile = conanfile\n            self._settings = self._conanfile.settings\n            self._output = self._conanfile.output\n            self.build_env = VisualStudioBuildEnvironment(self._conanfile)\n        else:  # backwards compatible with build_sln_command\n            self._settings = conanfile\n            self.build_env = None\n\n    def build(self, project_file, targets=None, upgrade_project=True, build_type=None, arch=None,\n              parallel=True, force_vcvars=False, toolset=None, platforms=None, use_env=True,\n              vcvars_ver=None, winsdk_version=None, properties=None):\n\n        self.build_env.parallel = parallel\n\n        with tools.environment_append(self.build_env.vars):\n            # Path for custom properties file\n            props_file_contents = self._get_props_file_contents()\n            with tmp_file(props_file_contents) as props_file_path:\n                vcvars = vcvars_command(self._conanfile.settings, force=force_vcvars,\n                                        vcvars_ver=vcvars_ver, winsdk_version=winsdk_version)\n                command = self.get_command(project_file, props_file_path,\n                                           targets=targets, upgrade_project=upgrade_project,\n                                           build_type=build_type, arch=arch, parallel=parallel,\n                                           toolset=toolset, platforms=platforms,\n                                           use_env=use_env, properties=properties)\n                command = \"%s && %s\" % (vcvars, command)\n                return self._conanfile.run(command)\n\n    def get_command(self, project_file, props_file_path=None, targets=None, upgrade_project=True,\n                    build_type=None, arch=None, parallel=True, toolset=None, platforms=None,\n                    use_env=False, properties=None):\n\n        targets = targets or []\n        properties = properties or {}\n        command = []\n\n        if upgrade_project and not get_env(\"CONAN_SKIP_VS_PROJECTS_UPGRADE\", False):\n            command.append('devenv \"%s\" /upgrade &&' % project_file)\n        else:\n            self._output.info(\"Skipped sln project upgrade\")\n\n        build_type = build_type or self._settings.get_safe(\"build_type\")\n        arch = arch or self._settings.get_safe(\"arch\")\n        if not build_type:\n            raise ConanException(\"Cannot build_sln_command, build_type not defined\")\n        if not arch:\n            raise ConanException(\"Cannot build_sln_command, arch not defined\")\n\n        command.append('msbuild \"%s\" /p:Configuration=\"%s\"' % (project_file, build_type))\n        msvc_arch = {'x86': 'x86',\n                     'x86_64': 'x64',\n                     'armv7': 'ARM',\n                     'armv8': 'ARM64'}\n        if platforms:\n            msvc_arch.update(platforms)\n        msvc_arch = msvc_arch.get(str(arch))\n        try:\n            sln = tools.load(project_file)\n            pattern = re.compile(r\"GlobalSection\\(SolutionConfigurationPlatforms\\)\"\n                                 r\"(.*?)EndGlobalSection\", re.DOTALL)\n            solution_global = pattern.search(sln).group(1)\n            lines = solution_global.splitlines()\n            lines = [s.split(\"=\")[0].strip() for s in lines]\n        except Exception:\n            pass\n        else:\n            config = \"%s|%s\" % (build_type, msvc_arch)\n            if config not in \"\".join(lines):\n                self._output.warn(\"***** The configuration %s does not exist in this solution *****\" % config)\n                self._output.warn(\"Use 'platforms' argument to define your architectures\")\n\n        if use_env:\n            command.append('/p:UseEnv=true')\n\n        if msvc_arch:\n            command.append('/p:Platform=\"%s\"' % msvc_arch)\n\n        if parallel:\n            command.append('/m:%s' % cpu_count())\n\n        if targets:\n            command.append(\"/target:%s\" % \";\".join(targets))\n\n        if toolset:\n            command.append('/p:PlatformToolset=\"%s\"' % toolset)\n\n        if props_file_path:\n            command.append('/p:ForceImportBeforeCppTargets=\"%s\"' % props_file_path)\n\n        for name, value in properties.items():\n            command.append('/p:%s=\"%s\"' % (name, value))\n\n        return \" \".join(command)\n\n    def _get_props_file_contents(self):\n        # how to specify runtime in command line:\n        # https://stackoverflow.com/questions/38840332/msbuild-overrides-properties-while-building-vc-project\n        runtime_library = {\"MT\": \"MultiThreaded\",\n                           \"MTd\": \"MultiThreadedDebug\",\n                           \"MD\": \"MultiThreadedDLL\",\n                           \"MDd\": \"MultiThreadedDebugDLL\"}.get(self._settings.get_safe(\"compiler.runtime\"), \"\")\n\n        if self.build_env:\n            # Take the flags from the build env, the user was able to alter them if needed\n            flags = copy.copy(self.build_env.flags)\n            flags.append(self.build_env.std)\n        else:  # To be removed when build_sln_command is deprecated\n            flags = vs_build_type_flags(self._settings)\n            flags.append(vs_std_cpp(self._settings))\n\n        flags_str = \" \".join(list(filter(None, flags))) # Removes empty and None elements\n        additional_node = \"<AdditionalOptions>\" \\\n                          \"{} %(AdditionalOptions)\" \\\n                          \"</AdditionalOptions>\".format(flags_str) if flags_str else \"\"\n        runtime_node = \"<RuntimeLibrary>\" \\\n                       \"{}\" \\\n                       \"</RuntimeLibrary>\".format(runtime_library) if runtime_library else \"\"\n        template = \"\"\"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemDefinitionGroup>\n    <ClCompile>\n      {runtime_node}\n      {additional_node}\n    </ClCompile>\n  </ItemDefinitionGroup>\n</Project>\"\"\".format(**{\"runtime_node\": runtime_node,\n                        \"additional_node\": additional_node})\n        return template\n", "path": "conans/client/build/msbuild.py"}], "after_files": [{"content": "import copy\nimport re\nimport subprocess\n\nfrom conans import tools\nfrom conans.client.build.visual_environment import (VisualStudioBuildEnvironment,\n                                                    vs_build_type_flags, vs_std_cpp)\nfrom conans.client.tools.oss import cpu_count\nfrom conans.client.tools.win import vcvars_command\nfrom conans.errors import ConanException\nfrom conans.model.version import Version\nfrom conans.util.env_reader import get_env\nfrom conans.util.files import tmp_file, decode_text\nfrom conans.model.conan_file import ConanFile\n\n\nclass MSBuild(object):\n\n    def __init__(self, conanfile):\n        if isinstance(conanfile, ConanFile):\n            self._conanfile = conanfile\n            self._settings = self._conanfile.settings\n            self._output = self._conanfile.output\n            self.build_env = VisualStudioBuildEnvironment(self._conanfile)\n        else:  # backwards compatible with build_sln_command\n            self._settings = conanfile\n            self.build_env = None\n\n    def build(self, project_file, targets=None, upgrade_project=True, build_type=None, arch=None,\n              parallel=True, force_vcvars=False, toolset=None, platforms=None, use_env=True,\n              vcvars_ver=None, winsdk_version=None, properties=None, output_binary_log=None):\n\n        self.build_env.parallel = parallel\n\n        with tools.environment_append(self.build_env.vars):\n            # Path for custom properties file\n            props_file_contents = self._get_props_file_contents()\n            with tmp_file(props_file_contents) as props_file_path:\n                vcvars = vcvars_command(self._conanfile.settings, force=force_vcvars,\n                                        vcvars_ver=vcvars_ver, winsdk_version=winsdk_version)\n                command = self.get_command(project_file, props_file_path,\n                                           targets=targets, upgrade_project=upgrade_project,\n                                           build_type=build_type, arch=arch, parallel=parallel,\n                                           toolset=toolset, platforms=platforms,\n                                           use_env=use_env, properties=properties, output_binary_log=output_binary_log)\n                command = \"%s && %s\" % (vcvars, command)\n                return self._conanfile.run(command)\n\n    def get_command(self, project_file, props_file_path=None, targets=None, upgrade_project=True,\n                    build_type=None, arch=None, parallel=True, toolset=None, platforms=None,\n                    use_env=False, properties=None, output_binary_log=None):\n\n        targets = targets or []\n        properties = properties or {}\n        command = []\n\n        if upgrade_project and not get_env(\"CONAN_SKIP_VS_PROJECTS_UPGRADE\", False):\n            command.append('devenv \"%s\" /upgrade &&' % project_file)\n        else:\n            self._output.info(\"Skipped sln project upgrade\")\n\n        build_type = build_type or self._settings.get_safe(\"build_type\")\n        arch = arch or self._settings.get_safe(\"arch\")\n        if not build_type:\n            raise ConanException(\"Cannot build_sln_command, build_type not defined\")\n        if not arch:\n            raise ConanException(\"Cannot build_sln_command, arch not defined\")\n\n        command.append('msbuild \"%s\" /p:Configuration=\"%s\"' % (project_file, build_type))\n        msvc_arch = {'x86': 'x86',\n                     'x86_64': 'x64',\n                     'armv7': 'ARM',\n                     'armv8': 'ARM64'}\n        if platforms:\n            msvc_arch.update(platforms)\n        msvc_arch = msvc_arch.get(str(arch))\n        try:\n            sln = tools.load(project_file)\n            pattern = re.compile(r\"GlobalSection\\(SolutionConfigurationPlatforms\\)\"\n                                 r\"(.*?)EndGlobalSection\", re.DOTALL)\n            solution_global = pattern.search(sln).group(1)\n            lines = solution_global.splitlines()\n            lines = [s.split(\"=\")[0].strip() for s in lines]\n        except Exception:\n            pass\n        else:\n            config = \"%s|%s\" % (build_type, msvc_arch)\n            if config not in \"\".join(lines):\n                self._output.warn(\"***** The configuration %s does not exist in this solution *****\" % config)\n                self._output.warn(\"Use 'platforms' argument to define your architectures\")\n\n        if output_binary_log:\n            msbuild_version = MSBuild.get_version(self._settings)\n            if msbuild_version >= \"15.3\":  # http://msbuildlog.com/\n                command.append('/bl' if isinstance(output_binary_log, bool)\n                               else '/bl:\"%s\"' % output_binary_log)\n            else:\n                raise ConanException(\"MSBuild version detected (%s) does not support \"\n                                     \"'output_binary_log' ('/bl')\" % msbuild_version)\n\n        if use_env:\n            command.append('/p:UseEnv=true')\n\n        if msvc_arch:\n            command.append('/p:Platform=\"%s\"' % msvc_arch)\n\n        if parallel:\n            command.append('/m:%s' % cpu_count())\n\n        if targets:\n            command.append(\"/target:%s\" % \";\".join(targets))\n\n        if toolset:\n            command.append('/p:PlatformToolset=\"%s\"' % toolset)\n\n        if props_file_path:\n            command.append('/p:ForceImportBeforeCppTargets=\"%s\"' % props_file_path)\n\n        for name, value in properties.items():\n            command.append('/p:%s=\"%s\"' % (name, value))\n\n        return \" \".join(command)\n\n    def _get_props_file_contents(self):\n        # how to specify runtime in command line:\n        # https://stackoverflow.com/questions/38840332/msbuild-overrides-properties-while-building-vc-project\n        runtime_library = {\"MT\": \"MultiThreaded\",\n                           \"MTd\": \"MultiThreadedDebug\",\n                           \"MD\": \"MultiThreadedDLL\",\n                           \"MDd\": \"MultiThreadedDebugDLL\"}.get(self._settings.get_safe(\"compiler.runtime\"), \"\")\n\n        if self.build_env:\n            # Take the flags from the build env, the user was able to alter them if needed\n            flags = copy.copy(self.build_env.flags)\n            flags.append(self.build_env.std)\n        else:  # To be removed when build_sln_command is deprecated\n            flags = vs_build_type_flags(self._settings)\n            flags.append(vs_std_cpp(self._settings))\n\n        flags_str = \" \".join(list(filter(None, flags))) # Removes empty and None elements\n        additional_node = \"<AdditionalOptions>\" \\\n                          \"{} %(AdditionalOptions)\" \\\n                          \"</AdditionalOptions>\".format(flags_str) if flags_str else \"\"\n        runtime_node = \"<RuntimeLibrary>\" \\\n                       \"{}\" \\\n                       \"</RuntimeLibrary>\".format(runtime_library) if runtime_library else \"\"\n        template = \"\"\"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemDefinitionGroup>\n    <ClCompile>\n      {runtime_node}\n      {additional_node}\n    </ClCompile>\n  </ItemDefinitionGroup>\n</Project>\"\"\".format(**{\"runtime_node\": runtime_node,\n                        \"additional_node\": additional_node})\n        return template\n\n    @staticmethod\n    def get_version(settings):\n        msbuild_cmd = \"msbuild -version\"\n        vcvars = vcvars_command(settings)\n        command = \"%s && %s\" % (vcvars, msbuild_cmd)\n        try:\n            out, err = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True).communicate()\n            version_line = decode_text(out).split(\"\\n\")[-1]\n            prog = re.compile(\"(\\d+\\.){2,3}\\d+\")\n            result = prog.match(version_line).group()\n            return Version(result)\n        except Exception as e:\n            raise ConanException(\"Error retrieving MSBuild version: '{}'\".format(e))\n", "path": "conans/client/build/msbuild.py"}]}