Skip to content

Instantly share code, notes, and snippets.

@tmenier
Created February 24, 2014 23:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tmenier/9199441 to your computer and use it in GitHub Desktop.
Save tmenier/9199441 to your computer and use it in GitHub Desktop.
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