Merge pull request #1879 from mellinoe/directory-delete-helper
Add a directory-delete helper.
This commit is contained in:
commit
42a0eec967
4 changed files with 21 additions and 16 deletions
|
@ -112,9 +112,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
if (Directory.Exists(wixObjRoot))
|
||||
{
|
||||
Directory.Delete(wixObjRoot, true);
|
||||
Utils.DeleteDirectory(wixObjRoot);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(wixObjRoot);
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
|
@ -137,9 +136,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
if (Directory.Exists(wixObjRoot))
|
||||
{
|
||||
Directory.Delete(wixObjRoot, true);
|
||||
Utils.DeleteDirectory(wixObjRoot);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(wixObjRoot);
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
|
|
|
@ -57,16 +57,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
if (Directory.Exists(cliSdkRoot))
|
||||
{
|
||||
string[] files = Directory.GetFiles(cliSdkRoot, "*", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
Directory.Delete(cliSdkRoot, true);
|
||||
Utils.DeleteDirectory(cliSdkRoot);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(cliSdk);
|
||||
|
||||
var binPath = Path.Combine(Dirs.Stage2, "bin");
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
if (Directory.Exists(SharedFrameworkPublishRoot))
|
||||
{
|
||||
Directory.Delete(SharedFrameworkPublishRoot, true);
|
||||
Utils.DeleteDirectory(SharedFrameworkPublishRoot);
|
||||
}
|
||||
|
||||
// We publish to a sub folder of the PublishRoot so tools like heat and zip can generate folder structures easier.
|
||||
|
@ -113,11 +113,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public static BuildTargetResult PublishSharedHost(BuildTargetContext c)
|
||||
{
|
||||
string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost");
|
||||
|
||||
if (Directory.Exists(SharedHostPublishRoot))
|
||||
{
|
||||
Directory.Delete(SharedHostPublishRoot);
|
||||
Utils.DeleteDirectory(SharedHostPublishRoot);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(SharedHostPublishRoot);
|
||||
|
||||
// corehost will be renamed to dotnet at some point and then this can be removed.
|
||||
|
|
|
@ -85,5 +85,20 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
b[x] = b[y];
|
||||
b[y] = t;
|
||||
}
|
||||
|
||||
public static void DeleteDirectory(string path)
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
Directory.Delete(path, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue