# This script is intended to be executed from the unsigned or signed folder downloaded from CI_SurfaceDiagnostics
# It will clean up the directory structure so that the TDM testing teams can easily use SDT without understanding
# the rest of the file structure

if(!(Test-Path .\Microsoft.Surface.Diagnostics.App.Wpf.exe))
{
    Write-Host "Invalid directory. Please run script directly from the unsigned/prodsigned folder from CI_SurfaceDiagnostics pipeline."
    Exit -1
}

# Files to copy into root
Copy-Item -Path ".\config_ASP\SurfaceDiagnosticToolkit.json" -Destination ".\SurfaceDiagnosticToolkit.json" -Force
Expand-Archive -Path ".\TdmSupportFiles.zip" -DestinationPath ".\"

# Files to delete
$itemsToDelete = @(
    ".\Microsoft.Surface.Diagnostics.App.Console.exe",
    ".\Microsoft.Surface.Diagnostics.App.Wpf.DesktopBridge.exe",
    ".\Microsoft Surface Diagnostic Toolkit for Business Installer.msi",
    ".\ResourceFiles.zip",
    ".\TdmSupportFiles.zip",
    ".\config_ASP",
    ".\config_Commercial",
    ".\config_RnR",
    ".\modules"
)

foreach($item in $itemsToDelete)
{
    Remove-Item -Path $item -Recurse -Force -ErrorAction Ignore
}

Unblock-File *
