Repository: conan-io/conan

Issue:
Visual Build tools doesn't include devenv
So, we need a way, as consumers, to specify that we don't want to upgrade the sln projects.


Discussion:

Resolving patch:
diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py
--- a/conans/client/conf/__init__.py
+++ b/conans/client/conf/__init__.py
@@ -93,6 +93,7 @@
 # pylintrc = path/to/pylintrc_file    # environment CONAN_PYLINTRC
 # cache_no_locks = True
 # user_home_short = your_path         # environment CONAN_USER_HOME_SHORT
+# skip_vs_projects_upgrade = False    # environment CONAN_SKIP_VS_PROJECTS_UPGRADE
 
 # conan_make_program = make           # environment CONAN_MAKE_PROGRAM (overrides the make program used in AutoToolsBuildEnvironment.make)
 
@@ -186,6 +187,7 @@ def env_vars(self):
                "CONAN_BASH_PATH": self._env_c("general.bash_path", "CONAN_BASH_PATH", None),
                "CONAN_MAKE_PROGRAM": self._env_c("general.conan_make_program", "CONAN_MAKE_PROGRAM", None),
                "CONAN_TEMP_TEST_FOLDER": self._env_c("general.temp_test_folder", "CONAN_TEMP_TEST_FOLDER", "False"),
+               "CONAN_SKIP_VS_PROJECTS_UPGRADE": self._env_c("general.skip_vs_projects_upgrade", "CONAN_SKIP_VS_PROJECTS_UPGRADE", "False")
                }
 
         # Filter None values
diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py
--- a/conans/client/tools/win.py
+++ b/conans/client/tools/win.py
@@ -5,7 +5,6 @@
 import re
 
 import subprocess
-from collections import OrderedDict
 from contextlib import contextmanager
 
 from conans.client.tools.env import environment_append
@@ -37,7 +36,13 @@ def build_sln_command(settings, sln_path, targets=None, upgrade_project=True, bu
         self.run(command)
     """
     targets = targets or []
-    command = "devenv %s /upgrade && " % sln_path if upgrade_project else ""
+    command = ""
+
+    if upgrade_project and not get_env("CONAN_SKIP_VS_PROJECTS_UPGRADE", False):
+        command += "devenv %s /upgrade && " % sln_path
+    else:
+        _global_output.info("Skipped sln project upgrade")
+
     build_type = build_type or settings.build_type
     arch = arch or settings.arch
     if not build_type:


Test patch:
diff --git a/conans/test/build_helpers/msbuild_test.py b/conans/test/build_helpers/msbuild_test.py
--- a/conans/test/build_helpers/msbuild_test.py
+++ b/conans/test/build_helpers/msbuild_test.py
@@ -3,6 +3,7 @@
 
 from nose.plugins.attrib import attr
 
+from conans import tools
 from conans.paths import CONANFILE
 from conans.test.utils.tools import TestClient
 from conans.test.utils.visual_project_files import get_vs_project_files
@@ -50,6 +51,15 @@ def package(self):
         files = get_vs_project_files()
         files[CONANFILE] = conan_build_vs
 
+        # Try to not update the project
+        client.client_cache._conan_config = None  # Invalidate cached config
+        tools.replace_in_file(client.client_cache.conan_conf_path, "[general]",
+                              "[general]\nskip_vs_projects_upgrade = True")
+        client.save(files, clean_first=True)
+        client.run("create . Hello/1.2.1@lasote/stable --build")
+        self.assertNotIn("devenv", client.user_io.out)
+        self.assertIn("Skipped sln project upgrade", client.user_io.out)
+
         # Try with x86_64
         client.save(files)
         client.run("export . lasote/stable")
diff --git a/conans/test/util/build_sln_command_test.py b/conans/test/util/build_sln_command_test.py
--- a/conans/test/util/build_sln_command_test.py
+++ b/conans/test/util/build_sln_command_test.py
@@ -2,6 +2,8 @@
 # -*- coding: utf-8 -*-
 
 import unittest
+
+from conans import tools
 from conans.tools import build_sln_command, cpu_count
 from conans.errors import ConanException
 from conans.model.settings import Settings
@@ -38,6 +40,22 @@ def upgrade_test(self):
         self.assertNotIn('/m:%s' % cpu_count(), command)
         self.assertNotIn('/target:teapot', command)
 
+        with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "1"}):
+            command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None,
+                                        upgrade_project=True,
+                                        build_type='Debug', arch='x86_64', parallel=False)
+            self.assertIn('msbuild dummy.sln', command)
+            self.assertIn('/p:Platform="x64"', command)
+            self.assertNotIn('devenv dummy.sln /upgrade', command)
+            self.assertNotIn('/m:%s' % cpu_count(), command)
+            self.assertNotIn('/target:teapot', command)
+
+        with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "False"}):
+            command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None,
+                                        upgrade_project=True,
+                                        build_type='Debug', arch='x86_64', parallel=False)
+            self.assertIn('devenv dummy.sln /upgrade', command)
+
     def parallel_test(self):
         command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True,
                                     build_type='Debug', arch='armv7', parallel=False)