diff --git a/Bonsai.Configuration/AssemblyLocationCollection.cs b/Bonsai.Configuration/AssemblyLocationCollection.cs index 48f09a40..3ece7bb9 100644 --- a/Bonsai.Configuration/AssemblyLocationCollection.cs +++ b/Bonsai.Configuration/AssemblyLocationCollection.cs @@ -4,16 +4,16 @@ namespace Bonsai.Configuration { [Serializable] - public class AssemblyLocationCollection : SortedKeyedCollection, AssemblyLocation> + public class AssemblyLocationCollection : SortedKeyedCollection<(string, ProcessorArchitecture), AssemblyLocation> { public void Add(string name, ProcessorArchitecture processorArchitecture, string path) { Add(new AssemblyLocation(name, processorArchitecture, path)); } - protected override Tuple GetKeyForItem(AssemblyLocation item) + protected override (string, ProcessorArchitecture) GetKeyForItem(AssemblyLocation item) { - return Tuple.Create(item.AssemblyName, item.ProcessorArchitecture); + return (item.AssemblyName, item.ProcessorArchitecture); } } } diff --git a/Bonsai.Configuration/ConfigurationHelper.cs b/Bonsai.Configuration/ConfigurationHelper.cs index 6addab57..3d2e4b2a 100644 --- a/Bonsai.Configuration/ConfigurationHelper.cs +++ b/Bonsai.Configuration/ConfigurationHelper.cs @@ -53,13 +53,13 @@ public static string GetConfigurationRoot(PackageConfiguration configuration = n public static string GetAssemblyLocation(this PackageConfiguration configuration, string assemblyName) { - var msilAssembly = Tuple.Create(assemblyName, ProcessorArchitecture.MSIL); + var msilAssembly = (assemblyName, ProcessorArchitecture.MSIL); if (configuration.AssemblyLocations.Contains(msilAssembly)) { return configuration.AssemblyLocations[msilAssembly].Location; } - var architectureSpecificAssembly = Tuple.Create(assemblyName, Environment.Is64BitProcess ? ProcessorArchitecture.Amd64 : ProcessorArchitecture.X86); + var architectureSpecificAssembly = (assemblyName, Environment.Is64BitProcess ? ProcessorArchitecture.Amd64 : ProcessorArchitecture.X86); if (configuration.AssemblyLocations.Contains(architectureSpecificAssembly)) { return configuration.AssemblyLocations[architectureSpecificAssembly].Location; @@ -209,7 +209,7 @@ public static void RegisterPath(this PackageConfiguration configuration, string catch (BadImageFormatException) { continue; } catch (IOException) { continue; } - var locationKey = Tuple.Create(assemblyName.Name, assemblyName.ProcessorArchitecture); + var locationKey = (assemblyName.Name, assemblyName.ProcessorArchitecture); if (!configuration.AssemblyLocations.Contains(locationKey)) { configuration.AssemblyReferences.Add(assemblyName.Name); diff --git a/Bonsai.Configuration/PackageConfigurationUpdater.cs b/Bonsai.Configuration/PackageConfigurationUpdater.cs index 19746c0b..db667a21 100644 --- a/Bonsai.Configuration/PackageConfigurationUpdater.cs +++ b/Bonsai.Configuration/PackageConfigurationUpdater.cs @@ -58,6 +58,7 @@ public PackageConfigurationUpdater(NuGetFramework projectFramework, PackageConfi var galleryPath = Path.Combine(bootstrapperDirectory, GalleryDirectory); var galleryPackageSource = new PackageSource(galleryPath); galleryRepository = new SourceRepository(galleryPackageSource, Repository.Provider.GetCoreV3()); + NormalizePathSeparators(packageConfiguration); } string GetRelativePath(string path) @@ -69,6 +70,28 @@ string GetRelativePath(string path) return PathUtility.GetPathWithDirectorySeparator(relativeUri.ToString()); } + static string CombinePath(string path1, string path2) + { + return PathUtility.GetPathWithForwardSlashes(Path.Combine(path1, path2)); + } + + static void NormalizePathSeparators(PackageConfiguration configuration) + { + foreach (var assemblyLocation in configuration.AssemblyLocations) + { + assemblyLocation.Location = PathUtility.GetPathWithForwardSlashes(assemblyLocation.Location); + } + + // cannot normalize in place since path is collection key + var libraryFolders = configuration.LibraryFolders.ToArray(); + configuration.LibraryFolders.Clear(); + foreach (var folder in libraryFolders) + { + folder.Path = PathUtility.GetPathWithForwardSlashes(folder.Path); + configuration.LibraryFolders.Add(folder); + } + } + static bool IsTaggedPackage(PackageReaderBase package) { var tags = package.NuspecReader.GetTags(); @@ -123,7 +146,7 @@ static IEnumerable GetAssemblyLocations(NuGetFramework projectFramework, return from file in nearestFramework.Items where Path.GetExtension(file) == AssemblyExtension && !string.IsNullOrEmpty(ResolvePathPlatformName(file)) - select PathUtility.GetPathWithDirectorySeparator(file); + select PathUtility.GetPathWithForwardSlashes(file); } static IEnumerable GetLibraryFolders(PackageReaderBase package, string installPath) @@ -143,7 +166,7 @@ static IEnumerable GetBuildLibraryFolders(PackageReaderBase packa group file by Path.GetDirectoryName(file) into folder let platform = ResolvePathPlatformName(folder.Key) where !string.IsNullOrWhiteSpace(platform) - select new LibraryFolder(Path.Combine(installPath, folder.Key), platform); + select new LibraryFolder(CombinePath(installPath, folder.Key), platform); } static IEnumerable GetRuntimeLibraryFolders(PackageReaderBase package, string installPath) @@ -154,14 +177,14 @@ where NuGetFramework.FrameworkNameComparer.Equals(frameworkGroup.TargetFramework where !string.IsNullOrWhiteSpace(platform) from file in frameworkGroup.Items group file by new { platform, path = Path.GetDirectoryName(file) } into folder - select new LibraryFolder(Path.Combine(installPath, folder.Key.path), folder.Key.platform); + select new LibraryFolder(CombinePath(installPath, folder.Key.path), folder.Key.platform); } static IEnumerable GetCompatibleAssemblyReferences(NuGetFramework projectFramework, PackageReaderBase package) { var nearestFramework = package.GetReferenceItems().GetNearest(projectFramework); if (nearestFramework == null) return Enumerable.Empty(); - return nearestFramework.Items.Select(PathUtility.GetPathWithDirectorySeparator); + return nearestFramework.Items.Select(PathUtility.GetPathWithForwardSlashes); } void RegisterAssemblyLocations(PackageReaderBase package, string installPath, string relativePath, bool addReferences) @@ -174,10 +197,10 @@ void RegisterAssemblyLocations(IEnumerable assemblyLocations, string ins { foreach (var path in assemblyLocations) { - var assemblyFile = Path.Combine(installPath, path); + var assemblyFile = CombinePath(installPath, path); var assemblyName = AssemblyName.GetAssemblyName(assemblyFile); - var assemblyLocation = Path.Combine(relativePath, path); - var assemblyLocationKey = Tuple.Create(assemblyName.Name, assemblyName.ProcessorArchitecture); + var assemblyLocation = CombinePath(relativePath, path); + var assemblyLocationKey = (assemblyName.Name, assemblyName.ProcessorArchitecture); if (!packageConfiguration.AssemblyLocations.Contains(assemblyLocationKey)) { packageConfiguration.AssemblyLocations.Add(assemblyName.Name, assemblyName.ProcessorArchitecture, assemblyLocation); @@ -204,11 +227,11 @@ void RemoveAssemblyLocations(IEnumerable assemblyLocations, string insta { foreach (var path in assemblyLocations) { - var assemblyFile = Path.Combine(installPath, path); + var assemblyFile = CombinePath(installPath, path); var location = packageConfiguration.AssemblyLocations.FirstOrDefault(item => item.Location == assemblyFile); if (location != null) { - packageConfiguration.AssemblyLocations.Remove(Tuple.Create(location.AssemblyName, location.ProcessorArchitecture)); + packageConfiguration.AssemblyLocations.Remove((location.AssemblyName, location.ProcessorArchitecture)); if (removeReference) { packageConfiguration.AssemblyReferences.Remove(location.AssemblyName);