Verify that the assembly is in the TPA list.
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / ni_common.cc
index ce2cff1..69c2dcf 100644 (file)
@@ -453,10 +453,20 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R,
        if (appPaths.back() == ':')
                appPaths.pop_back();
 
-       auto convert = [&appPaths, enableR2R, isAppNI](const std::string& path, const char* name) {
+       std::vector<std::string> tpaAssemblies;
+       splitPath(__tpa, tpaAssemblies);
+
+       auto convert = [&appPaths, enableR2R, isAppNI, tpaAssemblies](const std::string& path, const char* name) {
                if (isAppNI) {
                        std::string assembly = path.substr(path.rfind('/') + 1);
-                       if (strstr(replaceAll(__tpa, ".ni.dll", ".dll").c_str(), assembly.c_str()) != NULL) {
+                       bool isExist = false;
+                       for (auto& tpa : tpaAssemblies) {
+                               if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
+                                       isExist = true;
+                                       break;
+                               }
+                       }
+                       if (isExist) {
                                fprintf(stderr, "%s present in the TPA list skips generation of NI file.\n", path.c_str());
                                return;
                        }
@@ -469,6 +479,8 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R,
        for (int i = 0; i < count; i++) {
                scanFilesInDir(rootPaths[i], convert, 1);
        }
+
+       tpaAssemblies.clear();
 }
 
 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
@@ -522,7 +534,17 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
                return NI_ERROR_NONE;
        } else {
                std::string assembly = dllPath.substr(dllPath.rfind('/') + 1);
-               if (strstr(replaceAll(__tpa, ".ni.dll", ".dll").c_str(), assembly.c_str()) != NULL) {
+               std::vector<std::string> tpaAssemblies;
+               splitPath(__tpa, tpaAssemblies);
+               bool isExist = false;
+               for (auto& tpa : tpaAssemblies) {
+                       if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
+                               isExist = true;
+                               break;
+                       }
+               }
+               tpaAssemblies.clear();
+               if (isExist) {
                        fprintf(stderr, "%s present in the TPA list skips generation of NI file.\n", dllPath.c_str());
                        return NI_ERROR_NONE;
                } else {