From f769f9ea1c43cd4545b81e9d1079b359de289f4b Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Wed, 6 Jul 2016 16:12:13 +0200 Subject: [PATCH 1/3] Update LibraryExporterExtensions.cs --- .../LibraryExporterExtensions.cs | 120 ++++++++++-------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index 7e3440c02..fb863bd49 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -1,6 +1,7 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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; @@ -9,62 +10,77 @@ using Microsoft.DotNet.ProjectModel.Graph; namespace Microsoft.DotNet.Cli.Compiler.Common { - public static class LibraryExporterExtensions - { - public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) - { - return - exporter.GetDependencies(LibraryType.Project) - .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); - } + public static class LibraryExporterExtensions + { + public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) + { + return + exporter.GetDependencies(LibraryType.Project) + .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); + } - public static void CopyTo(this IEnumerable assets, string destinationPath) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + public static void CopyTo(this IEnumerable assets, string destinationPath) + { + 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); - } - } + foreach (var asset in assets) + { + var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + File.Copy(asset.ResolvedPath, file, overwrite: true); + RemoveFileAttribute(file, FileAttributes.ReadOnly); + } + } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + private static void RemoveFileAttribute(String file, FileAttributes attribute) + { + if (File.Exists(file)) + { + var fileAttributes = File.GetAttributes(file); + if ((fileAttributes & attribute) == attribute) + { + File.SetAttributes(file, fileAttributes & ~attribute); + } + } + } - foreach (var asset in assets) - { - var targetName = ResolveTargetName(destinationPath, asset); - var transformedFile = asset.GetTransformedFile(tempLocation); + public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - File.Copy(transformedFile, targetName, overwrite: true); - } - } + foreach (var asset in assets) + { + var targetName = ResolveTargetName(destinationPath, asset); + var transformedFile = asset.GetTransformedFile(tempLocation); - private static string ResolveTargetName(string destinationPath, LibraryAsset asset) - { - string targetName; - if (!string.IsNullOrEmpty(asset.RelativePath)) - { - targetName = Path.Combine(destinationPath, asset.RelativePath); - var destinationAssetPath = Path.GetDirectoryName(targetName); + File.Copy(transformedFile, targetName, overwrite: true); + RemoveFileAttribute(targetName, FileAttributes.ReadOnly); + } + } - if (!Directory.Exists(destinationAssetPath)) - { - Directory.CreateDirectory(destinationAssetPath); - } - } - else - { - targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - } - return targetName; - } - } + private static string ResolveTargetName(string destinationPath, LibraryAsset asset) + { + string targetName; + if (!string.IsNullOrEmpty(asset.RelativePath)) + { + targetName = Path.Combine(destinationPath, asset.RelativePath); + var destinationAssetPath = Path.GetDirectoryName(targetName); + + if (!Directory.Exists(destinationAssetPath)) + { + Directory.CreateDirectory(destinationAssetPath); + } + } + else + { + targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + } + return targetName; + } + } } From 2084a099b8323efdceaa3bd81fb9fb307b57eded Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Wed, 6 Jul 2016 16:55:35 +0200 Subject: [PATCH 2/3] Update LibraryExporterExtensions.cs tabs -> spaces --- .../LibraryExporterExtensions.cs | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index fb863bd49..bde36f966 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -10,77 +10,77 @@ using Microsoft.DotNet.ProjectModel.Graph; namespace Microsoft.DotNet.Cli.Compiler.Common { - public static class LibraryExporterExtensions - { - public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) - { - return - exporter.GetDependencies(LibraryType.Project) - .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); - } + public static class LibraryExporterExtensions + { + public static IEnumerable GetAllProjectTypeDependencies(this LibraryExporter exporter) + { + return + exporter.GetDependencies(LibraryType.Project) + .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); + } + + public static void CopyTo(this IEnumerable assets, string destinationPath) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - public static void CopyTo(this IEnumerable assets, string destinationPath) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + foreach (var asset in assets) + { + var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + File.Copy(asset.ResolvedPath, file, overwrite: true); + RemoveFileAttribute(file, FileAttributes.ReadOnly); + } + } - foreach (var asset in assets) - { - var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - File.Copy(asset.ResolvedPath, file, overwrite: true); - RemoveFileAttribute(file, FileAttributes.ReadOnly); - } - } + private static void RemoveFileAttribute(String file, FileAttributes attribute) + { + if (File.Exists(file)) + { + var fileAttributes = File.GetAttributes(file); + if ((fileAttributes & attribute) == attribute) + { + File.SetAttributes(file, fileAttributes & ~attribute); + } + } + } - private static void RemoveFileAttribute(String file, FileAttributes attribute) - { - if (File.Exists(file)) - { - var fileAttributes = File.GetAttributes(file); - if ((fileAttributes & attribute) == attribute) - { - File.SetAttributes(file, fileAttributes & ~attribute); - } - } - } + public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) + { + if (!Directory.Exists(destinationPath)) + { + Directory.CreateDirectory(destinationPath); + } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) - { - if (!Directory.Exists(destinationPath)) - { - Directory.CreateDirectory(destinationPath); - } + foreach (var asset in assets) + { + var targetName = ResolveTargetName(destinationPath, asset); + var transformedFile = asset.GetTransformedFile(tempLocation); - foreach (var asset in assets) - { - var targetName = ResolveTargetName(destinationPath, asset); - var transformedFile = asset.GetTransformedFile(tempLocation); + File.Copy(transformedFile, targetName, overwrite: true); + RemoveFileAttribute(targetName, FileAttributes.ReadOnly); + } + } - File.Copy(transformedFile, targetName, overwrite: true); - RemoveFileAttribute(targetName, FileAttributes.ReadOnly); - } - } + private static string ResolveTargetName(string destinationPath, LibraryAsset asset) + { + string targetName; + if (!string.IsNullOrEmpty(asset.RelativePath)) + { + targetName = Path.Combine(destinationPath, asset.RelativePath); + var destinationAssetPath = Path.GetDirectoryName(targetName); - private static string ResolveTargetName(string destinationPath, LibraryAsset asset) - { - string targetName; - if (!string.IsNullOrEmpty(asset.RelativePath)) - { - targetName = Path.Combine(destinationPath, asset.RelativePath); - var destinationAssetPath = Path.GetDirectoryName(targetName); - - if (!Directory.Exists(destinationAssetPath)) - { - Directory.CreateDirectory(destinationAssetPath); - } - } - else - { - targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); - } - return targetName; - } - } + if (!Directory.Exists(destinationAssetPath)) + { + Directory.CreateDirectory(destinationAssetPath); + } + } + else + { + targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); + } + return targetName; + } + } } From 38f75fd5c50de784017df8a97068972b52fc12a5 Mon Sep 17 00:00:00 2001 From: Dennis Fricke Date: Thu, 7 Jul 2016 15:16:10 +0200 Subject: [PATCH 3/3] Update LibraryExporterExtensions.cs - removed space | moved method below StructuredCopyTo --- .../LibraryExporterExtensions.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs index bde36f966..8c5cfc355 100644 --- a/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/LibraryExporterExtensions.cs @@ -18,7 +18,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common exporter.GetDependencies(LibraryType.Project) .Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); } - + public static void CopyTo(this IEnumerable assets, string destinationPath) { if (!Directory.Exists(destinationPath)) @@ -34,18 +34,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common } } - private static void RemoveFileAttribute(String file, FileAttributes attribute) - { - if (File.Exists(file)) - { - var fileAttributes = File.GetAttributes(file); - if ((fileAttributes & attribute) == attribute) - { - File.SetAttributes(file, fileAttributes & ~attribute); - } - } - } - public static void StructuredCopyTo(this IEnumerable assets, string destinationPath, string tempLocation) { if (!Directory.Exists(destinationPath)) @@ -62,6 +50,18 @@ namespace Microsoft.DotNet.Cli.Compiler.Common RemoveFileAttribute(targetName, FileAttributes.ReadOnly); } } + + private static void RemoveFileAttribute(String file, FileAttributes attribute) + { + if (File.Exists(file)) + { + var fileAttributes = File.GetAttributes(file); + if ((fileAttributes & attribute) == attribute) + { + File.SetAttributes(file, fileAttributes & ~attribute); + } + } + } private static string ResolveTargetName(string destinationPath, LibraryAsset asset) {