Exemple #1
0
        /// <summary>
        /// Provides the path to Xplat dll on the test machine.
        /// It traverses in the directory tree going one step up at a time and looks for src folder.
        /// Once in src, it looks for the xplat dll in the location specified by <code>_xplatDll</code>.
        /// </summary>
        /// <returns>
        /// <code>String</code> containing the path to the dotnet cli within the local repository.
        /// Can return <code>null</code> if no src directory or xplat dll is found, in which case the tests can fail.
        /// </returns>
        public static string GetXplatDll()
        {
            var dir = TestFileSystemUtility.ParentDirectoryLookup()
                      .FirstOrDefault(d => Directory.Exists(Path.Combine(d.FullName, "src")));

            if (dir != null)
            {
                const string configuration =
#if DEBUG
                    "Debug";
#else
                    "Release";
#endif

                var relativePaths = new string[]
                {
                    Path.Combine("artifacts", "NuGet.CommandLine.XPlat", "bin", configuration, "netcoreapp5.0", XPlatDll)
                };

                foreach (var relativePath in relativePaths)
                {
                    var filePath = Path.Combine(dir.FullName, relativePath);

                    if (File.Exists(filePath))
                    {
                        return(filePath);
                    }
                }
            }

            return(null);
        }