/// <summary> /// Return the matching framework/runtime ProjectContext. /// If 'nugetframework' or 'runtime' is null or empty then it matches with any. /// </summary> private static IEnumerable<ProjectContext> GetMatchingProjectContexts(IEnumerable<ProjectContext> contexts, NuGetFramework framework, string runtimeIdentifier) { foreach (var context in contexts) { if (context.TargetFramework == null || string.IsNullOrEmpty(context.RuntimeIdentifier)) { continue; } if (string.IsNullOrEmpty(runtimeIdentifier) || runtimeIdentifier.Equals(context.RuntimeIdentifier)) { if (framework == null || framework.Equals(context.TargetFramework)) { yield return context; } } } }
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); }
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; }
private static string GetEffectivePathForContentFile(NuGetFramework nuGetFramework, string zipArchiveEntryFullName) { // Always use Path.DirectorySeparatorChar var effectivePathForContentFile = PathUtility.ReplaceAltDirSeparatorWithDirSeparator(zipArchiveEntryFullName); if (effectivePathForContentFile.StartsWith(Constants.ContentDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) { effectivePathForContentFile = effectivePathForContentFile.Substring((Constants.ContentDirectory + Path.DirectorySeparatorChar).Length); if(!nuGetFramework.Equals(NuGetFramework.AnyFramework)) { // Parsing out the framework name out of the effective path int frameworkFolderEndIndex = effectivePathForContentFile.IndexOf(Path.DirectorySeparatorChar); if (frameworkFolderEndIndex != -1) { if (effectivePathForContentFile.Length > frameworkFolderEndIndex + 1) { effectivePathForContentFile = effectivePathForContentFile.Substring(frameworkFolderEndIndex + 1); } } return effectivePathForContentFile; } } // Return the effective path with Path.DirectorySeparatorChar return effectivePathForContentFile; }