From 2e71afc56dd0271f6507f77df96b219f550e284a Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 9 Feb 2016 12:01:52 -0800 Subject: [PATCH] Fix build for full clr --- .../Executable.cs | 31 +++++++++++++++---- .../LibraryExporterExtensions.cs | 15 ++++++--- .../commands/dotnet-publish/PublishCommand.cs | 2 +- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/Executable.cs b/src/Microsoft.DotNet.Compiler.Common/Executable.cs index eab60e6ef..2fc4ecfa9 100644 --- a/src/Microsoft.DotNet.Compiler.Common/Executable.cs +++ b/src/Microsoft.DotNet.Compiler.Common/Executable.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Linq; @@ -79,10 +80,15 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common private static void CopyAllDependencies(string outputPath, LibraryExporter exporter) { - exporter - .GetAllExports() - .SelectMany(e => e.RuntimeAssets()) + var libraryExports = exporter.GetAllExports(); + + libraryExports + .SelectMany(e => e.RuntimeAssemblies) .CopyTo(outputPath); + + libraryExports + .SelectMany(RuntimeAssets) + .StructuredCopyTo(outputPath); } private static void WriteDepsFileAndCopyProjectDependencies( @@ -94,11 +100,24 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common .GetDependencies(LibraryType.Package) .WriteDepsTo(Path.Combine(outputPath, projectFileName + FileNameSuffixes.Deps)); - exporter - .GetAllExports() + var projectExports = exporter.GetAllExports() .Where(e => e.Library.Identity.Type == LibraryType.Project) - .SelectMany(e => e.RuntimeAssets()) + .ToArray(); + + projectExports + .SelectMany(e => e.RuntimeAssemblies) .CopyTo(outputPath); + + projectExports + .SelectMany(RuntimeAssets) + .StructuredCopyTo(outputPath); + } + + + private static IEnumerable RuntimeAssets(LibraryExport export) + { + return export.NativeLibraries + .Union(export.RuntimeAssets); } public void GenerateBindingRedirects(LibraryExporter exporter) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index 2e1c3fd5e..bf7e7403f 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -40,13 +40,20 @@ namespace Microsoft.DotNet.Cli.Compiler.Common })); } - internal static IEnumerable RuntimeAssets(this LibraryExport export) + public static void CopyTo(this IEnumerable assets, string destinationPath) { - return export.RuntimeAssemblies.Union(export.NativeLibraries) - .Union(export.RuntimeAssets); + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } + + foreach (var asset in assets) + { + File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)), overwrite: true); + } } - public static void CopyTo(this IEnumerable assets, string destinationPath) + public static void StructuredCopyTo(this IEnumerable assets, string destinationPath) { if (!Directory.Exists(destinationPath)) { diff --git a/src/dotnet/commands/dotnet-publish/PublishCommand.cs b/src/dotnet/commands/dotnet-publish/PublishCommand.cs index 85f66f154..112712794 100644 --- a/src/dotnet/commands/dotnet-publish/PublishCommand.cs +++ b/src/dotnet/commands/dotnet-publish/PublishCommand.cs @@ -138,7 +138,7 @@ namespace Microsoft.DotNet.Tools.Publish PublishFiles(export.RuntimeAssemblies, outputPath, nativeSubdirectories: false); PublishFiles(export.NativeLibraries, outputPath, nativeSubdirectories); - export.RuntimeAssets.CopyTo(outputPath); + export.RuntimeAssets.StructuredCopyTo(outputPath); if (options.PreserveCompilationContext.GetValueOrDefault()) {