add check if no removable files to don't throw null error

This commit is contained in:
Dimitrij
2021-12-15 01:02:13 +00:00
parent d7e2358d3e
commit ad227ea2ee

View File

@@ -7,15 +7,15 @@ param (
[Parameter(Mandatory=$true)]
$ConfigurationName
)
Write-Output ""
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# Remove unnecessary files from Release versions
if ($ConfigurationName -match "Release") {
Write-Output "Removing unnecessary files from Release versions"
if ($ConfigurationName -match "Release")
{
$test = Join-Path -Path $TargetDir -ChildPath "app.publish"
if (Test-Path $test -PathType Container) {
if (Test-Path $test -PathType Container)
{
Remove-Item -Path (Join-Path -Path $TargetDir -ChildPath "app.publish") -Recurse -Force
}
@@ -29,10 +29,18 @@ if ($ConfigurationName -match "Release") {
) -Exclude @(
"mRemoteNG.VisualElementsManifest.xml"
)
Remove-Item -Path $filesToDelete.FullName
Write-Output $filesToDelete.FullName
if ($filesToDelete)
{
Write-Output "Unnecessary files are detected and will be removed"
Remove-Item -Path $filesToDelete.FullName
Write-Output $filesToDelete.FullName
} else
{
Write-Output " No unnecessary files are detected"
}
}
else {
else
{
Write-Output "We will not remove anything - this is not a release build."
}