private IEnumerable <string> GetRuntimeAssetFoldersForPromotion(ContentItemGroup runtimeAssets, NuGetFramework targetFramework, string targetFrameworkName)
        {
            if (runtimeAssets == null || runtimeAssets.Items.Count == 0)
            {
                return(Enumerable.Empty <string>());
            }

            if (runtimeAssets.Items.All(ci => NuGetAssetResolver.IsPlaceholder(ci.Path)))
            {
                return(Enumerable.Empty <string>());
            }

            if (targetFrameworkName == null)
            {
                targetFrameworkName = targetFramework.GetShortFolderName();
            }

            var resolvedFramework = runtimeAssets.Properties["tfm"] as NuGetFramework;

            if (targetFramework.Equals(resolvedFramework))
            {
                Log.LogMessage(LogImportance.Low, $"Not promoting explicit implementation for {targetFrameworkName}");
                return(Enumerable.Empty <string>());
            }

            return(NuGetAssetResolver.GetPackageTargetDirectories(runtimeAssets));
        }
Example #2
0
        private IEnumerable <string> GetObscuredAssetFolders(ContentItemGroup assets, ContentItemGroup obscuredAssets, NuGetFramework targetFramework, string targetFrameworkName, string expectedAssetFolder, string ignoredAssetFolder = null)
        {
            if (assets == null || assets.Items.Count == 0)
            {
                return(Enumerable.Empty <string>());
            }

            if (assets.Items.Any(ci => !NuGetAssetResolver.IsPlaceholder(ci.Path)))
            {
                return(Enumerable.Empty <string>());
            }

            if (targetFrameworkName == null)
            {
                targetFrameworkName = targetFramework.GetShortFolderName();
            }

            var resolvedFramework = assets.Properties["tfm"] as NuGetFramework;

            if (targetFramework.Equals(resolvedFramework))
            {
                Log.LogMessage(LogImportance.Low, $"Not overriding explicit placeholder for {targetFrameworkName}");
                return(Enumerable.Empty <string>());
            }

            var obscuredAssetPaths = NuGetAssetResolver.GetPackageTargetDirectories(obscuredAssets);

            if (ignoredAssetFolder != null)
            {
                string ignoredFolder = ignoredAssetFolder + '/';
                obscuredAssetPaths = obscuredAssetPaths.Where(i => - 1 == i.IndexOf(ignoredFolder, StringComparison.OrdinalIgnoreCase));
            }

            if (expectedAssetFolder != null)
            {
                var unexpectedAssetPaths = obscuredAssetPaths.Where(ri => !ri.StartsWith(expectedAssetFolder, StringComparison.OrdinalIgnoreCase));
                foreach (var unexpectedAssetPath in unexpectedAssetPaths)
                {
                    Log.LogWarning($"Unexpected targetPath {unexpectedAssetPath}.  Expected only {expectedAssetFolder}.");
                }

                // filter after we've warned
                obscuredAssetPaths = obscuredAssetPaths.Except(unexpectedAssetPaths);
            }

            if (!obscuredAssetPaths.Any())
            {
                // it's acceptable to have no override, this is the case for packages which
                // carry implementation in a runtime-specific package
                Log.LogMessage(LogImportance.Low, $"No {expectedAssetFolder} assets could be found to override inbox placeholder for {targetFrameworkName}.");
            }

            return(obscuredAssetPaths);
        }