-
-
Save developerprofiles/a16055f31b7243d021bd5b7bb4ffca44 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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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