Add a directory-delete helper.
This seems to be needed on Windows to delete temporary staging files correctly.
This commit is contained in:
parent
ffedcb315f
commit
23e024c463
4 changed files with 21 additions and 16 deletions
|
@ -112,9 +112,8 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
if (Directory.Exists(wixObjRoot))
|
if (Directory.Exists(wixObjRoot))
|
||||||
{
|
{
|
||||||
Directory.Delete(wixObjRoot, true);
|
Utils.DeleteDirectory(wixObjRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(wixObjRoot);
|
Directory.CreateDirectory(wixObjRoot);
|
||||||
|
|
||||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||||
|
@ -137,9 +136,8 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
if (Directory.Exists(wixObjRoot))
|
if (Directory.Exists(wixObjRoot))
|
||||||
{
|
{
|
||||||
Directory.Delete(wixObjRoot, true);
|
Utils.DeleteDirectory(wixObjRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(wixObjRoot);
|
Directory.CreateDirectory(wixObjRoot);
|
||||||
|
|
||||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||||
|
|
|
@ -57,16 +57,8 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
if (Directory.Exists(cliSdkRoot))
|
if (Directory.Exists(cliSdkRoot))
|
||||||
{
|
{
|
||||||
string[] files = Directory.GetFiles(cliSdkRoot, "*", SearchOption.AllDirectories);
|
Utils.DeleteDirectory(cliSdkRoot);
|
||||||
foreach (string file in files)
|
|
||||||
{
|
|
||||||
File.SetAttributes(file, FileAttributes.Normal);
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
Directory.Delete(cliSdkRoot, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(cliSdk);
|
Directory.CreateDirectory(cliSdk);
|
||||||
|
|
||||||
var binPath = Path.Combine(Dirs.Stage2, "bin");
|
var binPath = Path.Combine(Dirs.Stage2, "bin");
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
if (Directory.Exists(SharedFrameworkPublishRoot))
|
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.
|
// 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)
|
public static BuildTargetResult PublishSharedHost(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost");
|
string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost");
|
||||||
|
|
||||||
if (Directory.Exists(SharedHostPublishRoot))
|
if (Directory.Exists(SharedHostPublishRoot))
|
||||||
{
|
{
|
||||||
Directory.Delete(SharedHostPublishRoot);
|
Utils.DeleteDirectory(SharedHostPublishRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(SharedHostPublishRoot);
|
Directory.CreateDirectory(SharedHostPublishRoot);
|
||||||
|
|
||||||
// corehost will be renamed to dotnet at some point and then this can be removed.
|
// 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[x] = b[y];
|
||||||
b[y] = t;
|
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
Add a link
Reference in a new issue