Update LibraryExporterExtensions.cs

tabs -> spaces
This commit is contained in:
Dennis Fricke 2016-07-06 16:55:35 +02:00 committed by GitHub
parent f769f9ea1c
commit 2084a099b8

View file

@ -10,77 +10,77 @@ using Microsoft.DotNet.ProjectModel.Graph;
namespace Microsoft.DotNet.Cli.Compiler.Common namespace Microsoft.DotNet.Cli.Compiler.Common
{ {
public static class LibraryExporterExtensions public static class LibraryExporterExtensions
{ {
public static IEnumerable<LibraryExport> GetAllProjectTypeDependencies(this LibraryExporter exporter) public static IEnumerable<LibraryExport> GetAllProjectTypeDependencies(this LibraryExporter exporter)
{ {
return return
exporter.GetDependencies(LibraryType.Project) exporter.GetDependencies(LibraryType.Project)
.Concat(exporter.GetDependencies(LibraryType.MSBuildProject)); .Concat(exporter.GetDependencies(LibraryType.MSBuildProject));
} }
public static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath) public static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath)
{ {
if (!Directory.Exists(destinationPath)) if (!Directory.Exists(destinationPath))
{ {
Directory.CreateDirectory(destinationPath); Directory.CreateDirectory(destinationPath);
} }
foreach (var asset in assets) foreach (var asset in assets)
{ {
var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath));
File.Copy(asset.ResolvedPath, file, overwrite: true); File.Copy(asset.ResolvedPath, file, overwrite: true);
RemoveFileAttribute(file, FileAttributes.ReadOnly); RemoveFileAttribute(file, FileAttributes.ReadOnly);
} }
} }
private static void RemoveFileAttribute(String file, FileAttributes attribute) private static void RemoveFileAttribute(String file, FileAttributes attribute)
{ {
if (File.Exists(file)) if (File.Exists(file))
{ {
var fileAttributes = File.GetAttributes(file); var fileAttributes = File.GetAttributes(file);
if ((fileAttributes & attribute) == attribute) if ((fileAttributes & attribute) == attribute)
{ {
File.SetAttributes(file, fileAttributes & ~attribute); File.SetAttributes(file, fileAttributes & ~attribute);
} }
} }
} }
public static void StructuredCopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath, string tempLocation) public static void StructuredCopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath, string tempLocation)
{ {
if (!Directory.Exists(destinationPath)) if (!Directory.Exists(destinationPath))
{ {
Directory.CreateDirectory(destinationPath); Directory.CreateDirectory(destinationPath);
} }
foreach (var asset in assets) foreach (var asset in assets)
{ {
var targetName = ResolveTargetName(destinationPath, asset); var targetName = ResolveTargetName(destinationPath, asset);
var transformedFile = asset.GetTransformedFile(tempLocation); var transformedFile = asset.GetTransformedFile(tempLocation);
File.Copy(transformedFile, targetName, overwrite: true); File.Copy(transformedFile, targetName, overwrite: true);
RemoveFileAttribute(targetName, FileAttributes.ReadOnly); RemoveFileAttribute(targetName, FileAttributes.ReadOnly);
} }
} }
private static string ResolveTargetName(string destinationPath, LibraryAsset asset) private static string ResolveTargetName(string destinationPath, LibraryAsset asset)
{ {
string targetName; string targetName;
if (!string.IsNullOrEmpty(asset.RelativePath)) if (!string.IsNullOrEmpty(asset.RelativePath))
{ {
targetName = Path.Combine(destinationPath, asset.RelativePath); targetName = Path.Combine(destinationPath, asset.RelativePath);
var destinationAssetPath = Path.GetDirectoryName(targetName); var destinationAssetPath = Path.GetDirectoryName(targetName);
if (!Directory.Exists(destinationAssetPath)) if (!Directory.Exists(destinationAssetPath))
{ {
Directory.CreateDirectory(destinationAssetPath); Directory.CreateDirectory(destinationAssetPath);
} }
} }
else else
{ {
targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)); targetName = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath));
} }
return targetName; return targetName;
} }
} }
} }