Repository: conan-io/conan

Issue:
[Regression] Two dots in lib filename 
I use conan 1.16.0 on windows 10 and I have a package that has a lib file named `GTEngine.v12.lib`. If I run `conan install` which uses the `visual_studio_multi` generator, it adds the lib filename _without extension_ in `conanbuildinfo_debug_x64_v120.props` (I use x64/msvc2013 which is irrelevant). Version 1.15.0 keeps the `.lib` suffix in the property sheet, but 1.16.0 somehow removes it which results in a build error.

Thanks in advance

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [x] I've specified the Conan version, operating system version and any tool that can be relevant.
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:
Hi @cubimon, we need to check it (probably related to https://github.com/conan-io/conan/issues/5303), it could be a regression. I'll keep you updated.
@jgsogo the related issue is a loop.
Ups! It was #5303 (I'll edit my message too)
So I should update and remove the filename extension? and probably close this issue because it is a duplicate?
No, leave it open. I think it is a regression and we should fix it. Probably the bug was introduced here https://github.com/conan-io/conan/pull/5254/files. If it was working for you in the previous version, it should work now.

Resolving patch:
diff --git a/conans/client/build/visual_environment.py b/conans/client/build/visual_environment.py
--- a/conans/client/build/visual_environment.py
+++ b/conans/client/build/visual_environment.py
@@ -4,6 +4,7 @@
 from conans.client.build.compiler_flags import build_type_define, build_type_flags, format_defines, \
     include_path_option, parallel_compiler_cl_flag, visual_runtime
 from conans.client.build.cppstd_flags import cppstd_flag, cppstd_from_settings
+from conans.client.tools.files import VALID_LIB_EXTENSIONS
 
 
 class VisualStudioBuildEnvironment(object):
@@ -78,7 +79,8 @@ def _get_link_list(self):
         # FIXME: Conan 2.0. The libs are being added twice to visual_studio
         # one in the conanbuildinfo.props, and the other in the env-vars
         def format_lib(lib):
-            return lib if os.path.splitext(lib)[1] else '%s.lib' % lib
+            ext = os.path.splitext(lib)[1]
+            return lib if ext in VALID_LIB_EXTENSIONS else '%s.lib' % lib
 
         ret = [flag for flag in self.link_flags]  # copy
         ret.extend([format_lib(lib) for lib in self.libs])
diff --git a/conans/client/generators/visualstudio.py b/conans/client/generators/visualstudio.py
--- a/conans/client/generators/visualstudio.py
+++ b/conans/client/generators/visualstudio.py
@@ -3,6 +3,7 @@
 
 from conans.model import Generator
 from conans.paths import BUILD_INFO_VISUAL_STUDIO
+from conans.client.tools.files import VALID_LIB_EXTENSIONS
 
 
 class VisualStudioGenerator(Generator):
@@ -65,13 +66,17 @@ def filename(self):
         return BUILD_INFO_VISUAL_STUDIO
 
     def _format_properties(self, build_info, condition):
+        def has_valid_ext(lib):
+            ext = os.path.splitext(lib)[1]
+            return ext in VALID_LIB_EXTENSIONS
+
         fields = {
             'condition': condition,
             'bin_dirs': "".join("%s;" % p for p in build_info.bin_paths),
             'res_dirs': "".join("%s;" % p for p in build_info.res_paths),
             'include_dirs': "".join("%s;" % p for p in build_info.include_paths),
             'lib_dirs': "".join("%s;" % p for p in build_info.lib_paths),
-            'libs': "".join(['%s.lib;' % lib if not os.path.splitext(lib)[1]  # No extension
+            'libs': "".join(['%s.lib;' % lib if not has_valid_ext(lib)
                              else '%s;' % lib for lib in build_info.libs]),
             'definitions': "".join("%s;" % d for d in build_info.defines),
             'compiler_flags': " ".join(build_info.cxxflags + build_info.cflags),
diff --git a/conans/client/tools/files.py b/conans/client/tools/files.py
--- a/conans/client/tools/files.py
+++ b/conans/client/tools/files.py
@@ -15,6 +15,8 @@
 from conans.util.files import (_generic_algorithm_sum, load, save)
 
 UNIT_SIZE = 1000.0
+# Library extensions supported by collect_libs
+VALID_LIB_EXTENSIONS = (".so", ".lib", ".a", ".dylib", ".bc")
 
 
 @contextmanager
@@ -321,7 +323,7 @@ def collect_libs(conanfile, folder=None):
         files = os.listdir(lib_folder)
         for f in files:
             name, ext = os.path.splitext(f)
-            if ext in (".so", ".lib", ".a", ".dylib", ".bc"):
+            if ext in VALID_LIB_EXTENSIONS:
                 if ext != ".lib" and name.startswith("lib"):
                     name = name[3:]
                 if name in result:


Test patch:
diff --git a/conans/test/unittests/client/generators/visual_studio_multi_test.py b/conans/test/unittests/client/generators/visual_studio_multi_test.py
--- a/conans/test/unittests/client/generators/visual_studio_multi_test.py
+++ b/conans/test/unittests/client/generators/visual_studio_multi_test.py
@@ -86,3 +86,49 @@ def valid_xml_test(self, use_toolset):
                           "Project=\"conanbuildinfo_release_x64_v141.props\"/>", content_multi)
 
             os.unlink('conanbuildinfo_multi.props')
+
+    def addional_dependencies_test(self):
+
+        def validate_additional_dependencies(libname, additional_dep):
+            tempdir = temp_folder()
+            with chdir(tempdir):
+                conanfile = ConanFile(TestBufferConanOutput(), None)
+                conanfile.initialize(Settings({}), EnvValues())
+
+                ref = ConanFileReference.loads("MyPkg/0.1@user/testing")
+                cpp_info = CppInfo("dummy_root_folder1")
+                cpp_info.libs = [libname]
+                conanfile.deps_cpp_info.update(cpp_info, ref.name)
+
+                settings = Settings.loads(default_settings_yml)
+                settings.os = "Windows"
+                settings.arch = "x86_64"
+                settings.build_type = "Release"
+                settings.compiler = "Visual Studio"
+                settings.compiler.version = "15"
+                settings.compiler.runtime = "MD"
+                settings.compiler.toolset = "v141"
+                conanfile.settings = settings
+
+                generator = VisualStudioMultiGenerator(conanfile)
+                generator.output_path = ""
+                content = generator.content
+
+                self.assertIn('conanbuildinfo_release_x64_v141.props', content.keys())
+
+                content_release = content['conanbuildinfo_release_x64_v141.props']
+                self.assertIn("<AdditionalDependencies>"
+                              "{};%(AdditionalDependencies)"
+                              "</AdditionalDependencies>".format(additional_dep), content_release)
+
+        # regular
+        validate_additional_dependencies("foobar", "foobar.lib")
+
+        # .lib extension
+        validate_additional_dependencies("blah.lib", "blah.lib")
+
+        # extra dot dot
+        validate_additional_dependencies("foo.v12.core", "foo.v12.core.lib")
+
+        # extra dot dot + .lib
+        validate_additional_dependencies("foo.v12.core.lib", "foo.v12.core.lib")
diff --git a/conans/test/unittests/client/generators/visual_studio_test.py b/conans/test/unittests/client/generators/visual_studio_test.py
--- a/conans/test/unittests/client/generators/visual_studio_test.py
+++ b/conans/test/unittests/client/generators/visual_studio_test.py
@@ -104,3 +104,35 @@ def multi_config_test(self):
         self.assertIn(condition_debug, content)
         self.assertIn(condition_release, content)
         self.assertIn(condition_custom, content)
+
+    def addional_dependencies_test(self):
+
+        def validate_additional_dependencies(lib, additional_dep):
+            conanfile = ConanFile(TestBufferConanOutput(), None)
+            conanfile.initialize(Settings({}), EnvValues())
+            ref = ConanFileReference.loads("MyPkg/0.1@user/testing")
+            cpp_info = CppInfo("dummy_root_folder1")
+            cpp_info.libs = [lib]
+            conanfile.deps_cpp_info.update(cpp_info, ref.name)
+            generator = VisualStudioGenerator(conanfile)
+            self.assertIn("<AdditionalDependencies>"
+                          "{};%(AdditionalDependencies)"
+                          "</AdditionalDependencies>".format(additional_dep), generator.content)
+
+        # regular
+        validate_additional_dependencies("foobar", "foobar.lib")
+
+        # .lib extension
+        validate_additional_dependencies("blah.lib", "blah.lib")
+
+        # extra dot dot
+        validate_additional_dependencies("foo.v12.core", "foo.v12.core.lib")
+
+        # extra dot dot + .lib
+        validate_additional_dependencies("foo.v12.core.lib", "foo.v12.core.lib")
+
+        # extra case libiconv
+        validate_additional_dependencies("libiconv.dll.lib", "libiconv.dll.lib")
+
+        # extra case ffmpeg
+        validate_additional_dependencies("libavcodec.a", "libavcodec.a")