/// <summary> /// Creates the shortened version of the framework using the given mappings. /// </summary> public virtual string GetShortFolderName(IFrameworkNameProvider mappings) { // Check for rewrites var framework = mappings.GetShortNameReplacement(this); var sb = new StringBuilder(); if (IsSpecificFramework) { var shortFramework = string.Empty; // get the framework if (!mappings.TryGetShortIdentifier( GetFrameworkIdentifier(), out shortFramework)) { shortFramework = GetLettersAndDigitsOnly(framework.Framework); } if (string.IsNullOrEmpty(shortFramework)) { throw new FrameworkException(string.Format( CultureInfo.CurrentCulture, Strings.InvalidFrameworkIdentifier, shortFramework)); } // add framework sb.Append(shortFramework); // add the version if it is non-empty if (!AllFrameworkVersions) { sb.Append(mappings.GetVersionString(framework.Framework, framework.Version)); } if (IsPCL) { sb.Append("-"); IEnumerable <NuGetFramework> frameworks = null; if (framework.HasProfile && mappings.TryGetPortableFrameworks(framework.Profile, false, out frameworks) && frameworks.Any()) { var required = new HashSet <NuGetFramework>(frameworks, Comparer); // Normalize by removing all optional frameworks mappings.TryGetPortableFrameworks(framework.Profile, false, out frameworks); // sort the PCL frameworks by alphabetical order var sortedFrameworks = required.Select(e => e.GetShortFolderName(mappings)).OrderBy(e => e, StringComparer.OrdinalIgnoreCase).ToList(); sb.Append(string.Join("+", sortedFrameworks)); } else { throw new FrameworkException(string.Format( CultureInfo.CurrentCulture, Strings.MissingPortableFrameworks, framework.DotNetFrameworkName)); } } else if (IsNet5Era) { if (!string.IsNullOrEmpty(framework.Platform)) { sb.Append("-"); sb.Append(framework.Platform.ToLowerInvariant()); if (framework.PlatformVersion != FrameworkConstants.EmptyVersion) { sb.Append(mappings.GetVersionString(framework.Framework, framework.PlatformVersion)); } } } else { // add the profile var shortProfile = string.Empty; if (framework.HasProfile && !mappings.TryGetShortProfile(framework.Framework, framework.Profile, out shortProfile)) { // if we have a profile, but can't get a mapping, just use the profile as is shortProfile = framework.Profile; } if (!string.IsNullOrEmpty(shortProfile)) { sb.Append("-"); sb.Append(shortProfile); } } } else { // unsupported, any, agnostic sb.Append(Framework); } return(sb.ToString().ToLowerInvariant()); }