示例#1
0
        public void DiscoverMetadataProperties(PackageMetadata discoveredMetadata, string discoveryRoot)
        {
            // don't bother if this isn't a website
            if (!_fs.File.Exists(_fs.Path.Combine(discoveryRoot, "web.config")))
            {
                return;
            }

            // the name of the folder that contains the top-most web.config file should be the name of the website
            var webAppName = _fs.DirectoryInfo.FromDirectoryName(discoveryRoot).Name;

            // assuming this is a pre-compiled website there should be an assembly with this name in the bin folder
            string webAppAssemblyPath = _fs.Path.Combine(discoveryRoot, string.Format("bin\\{0}.dll", webAppName));

            if (_fs.File.Exists(webAppAssemblyPath))
            {
                _log.DebugFormat("Inferring package metadata for web application {0}", webAppAssemblyPath);
                _fromAssemblyMapper.MapAssemblyInfoToPackage(webAppAssemblyPath, discoveredMetadata);
            }

            if (string.IsNullOrWhiteSpace(discoveredMetadata.Id))
            {
                discoveredMetadata.Id = webAppName;
            }
            if (string.IsNullOrWhiteSpace(discoveredMetadata.Description))
            {
                discoveredMetadata.Description = webAppName + " description";
            }
        }
        public void DiscoverMetadataProperties(PackageMetadata discoveredMetadata, string discoveryRoot)
        {
            var exesFound = _fs.Directory.GetFiles(discoveryRoot, "*.exe", System.IO.SearchOption.AllDirectories).ToList();

            exesFound.RemoveAll(x => x.Contains(".vshost"));

            var expectedApplicationName   = _fs.DirectoryInfo.FromDirectoryName(discoveryRoot).Name;
            var exesFoundWithExpectedName = exesFound.Where(f => f.EndsWith(expectedApplicationName + ".exe")).ToArray();

            if (exesFoundWithExpectedName.Length == 1)
            {
                _fromAssemblyMapper.MapAssemblyInfoToPackage(exesFoundWithExpectedName[0], discoveredMetadata);
                return;
            }

            if (exesFound.Count == 1)
            {
                _fromAssemblyMapper.MapAssemblyInfoToPackage(exesFound[0], discoveredMetadata);
                return;
            }

            if (exesFound.Count > 1)
            {
                return;
            }

            var dllsFound = _fs.Directory.GetFiles(discoveryRoot, "*.dll", System.IO.SearchOption.AllDirectories).ToList();
            var dllsFoundWithExpectedName = dllsFound.Where(f => f.EndsWith(expectedApplicationName + ".dll")).ToArray();

            if (dllsFoundWithExpectedName.Length == 1)
            {
                _fromAssemblyMapper.MapAssemblyInfoToPackage(dllsFoundWithExpectedName[0], discoveredMetadata);
            }
            if (dllsFound.Count == 1)
            {
                _fromAssemblyMapper.MapAssemblyInfoToPackage(dllsFound[0], discoveredMetadata);
            }
        }