Skip to content

Instantly share code, notes, and snippets.

@bitbonk
Created January 10, 2017 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbonk/7771cef5d32b2c9b267d059469b97676 to your computer and use it in GitHub Desktop.
Save bitbonk/7771cef5d32b2c9b267d059469b97676 to your computer and use it in GitHub Desktop.
deploy something but exclude some stuff
<#
.SYNOPSIS
Copies the files that belong to a deployment to a target folder.
.PARAMETER Source
The path of the source folder.
.PARAMETER Target
The path of the target folder.
#>
[CmdletBinding(SupportsShouldProcess=$True)]
Param(
[Parameter(Mandatory=$True, Position=1, HelpMessage="The path of the source folder")]
[string] $Source,
[Parameter(Mandatory=$True, Position=2, HelpMessage="The path of the target folder")]
[string] $Target
)
$Source = Convert-Path $Source
$Target = Convert-Path $Target
Get-Childitem $Source -Recurse |
Where-Object { $_.fullname -notmatch "System.Windows.Interactivity.resources.dll|fluentassertions|\.dll\.config$|(System32|System64)\\(Debug|Release)\\(es|fr|hu|it|ja|ko|pt-br|ro|ru|sv|zh-Hans|zh-Hant)$"} |
ForEach-Object {
if($_.PSIsContainer -eq $false)
{
$targetFile = Join-Path $Target $_.FullName.SubString($Source.Length)
New-Item (Split-Path -Path $targetFile) -Force -ItemType Directory
Copy-Item -LiteralPath $_.FullName -Destination $targetFile -Force -Verbose:($PSBoundParameters['Verbose'] -eq $true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment