Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A PowerShell function to copy all deployable files from an ASP.NET Web Application project (WebForms or MVC) to another directory. Takes the path to the project file and the path to the destination folder. Useful in CI environments. In my tests, running this after msbuild has built the project is much faster than including a WebDeploy step in th…
function copy-deployable-web-files($proj_path, $deploy_dir) {
# copy files where Build Action = "Content"
$proj_dir = split-path -parent $proj_path
[xml]$xml = get-content $proj_path
$xml.Project.ItemGroup | % { $_.Content } | % { $_.Include } | ? { $_ } | % {
$from = "$proj_dir\$_"
$to = split-path -parent "$deploy_dir\$_"
if (!(test-path $to)) { md $to }
cp $from $to
}
# copy everything in bin
cp "$proj_dir\bin" $deploy_dir -recurse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.