Refactor output directory code
This commit is contained in:
parent
4908436958
commit
0f82ae37f3
49 changed files with 836 additions and 396 deletions
|
@ -40,20 +40,45 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
}));
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> RuntimeAssets(this LibraryExport export)
|
||||
internal static IEnumerable<LibraryAsset> RuntimeAssets(this LibraryExport export)
|
||||
{
|
||||
return export.RuntimeAssemblies.Union(export.NativeLibraries)
|
||||
.Select(e => e.ResolvedPath)
|
||||
.Union(export.RuntimeAssets);
|
||||
}
|
||||
|
||||
internal static void CopyTo(this IEnumerable<string> assets, string destinationPath)
|
||||
public static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath)
|
||||
{
|
||||
if (!Directory.Exists(destinationPath))
|
||||
{
|
||||
Directory.CreateDirectory(destinationPath);
|
||||
}
|
||||
|
||||
foreach (var asset in assets)
|
||||
{
|
||||
File.Copy(asset, Path.Combine(destinationPath, Path.GetFileName(asset)),
|
||||
overwrite: true);
|
||||
var targetName = ResolveTargetName(destinationPath, asset);
|
||||
|
||||
File.Copy(asset.ResolvedPath, targetName, overwrite: true);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue