How to publish web site using PSAKE
Is there a way to publish asp.net web application using PSAKE, just like visual st开发者_JAVA技巧udio do?
As per this post, here's another way of publishing your web application. I've used this technique for publishing an .asmx web service. The trick is the _CopyWebApplication
msbuild target, which makes the distributable files for your web app.
# ...setup properties
task PublishWebService -depends Compile {
$output_dir = "$build_dir\$configuration\Web"
$output_bin_dir = "$output_dir\bin\"
msbuild $webservice_project_file /t:ResolveReferences /t:_CopyWebApplication /p:Configuration=$configuration /p:WebProjectOutputDir="..\$output_dir" /p:OutDir="..\$output_bin_dir"
if (-not (Test-Path $web_service_inetpub_dir)) {
mkdir $web_service_inetpub_dir
}
copy $output_dir\* -destination $web_service_inetpub_dir -recurse -force
"Publish OK!"
}
See also this post for some information on setting up and tearing down IIS sites and app pools from within your psake script.
UPDATE: I've found the following commands to work a bit better. The one I posted above does not correctly apply web.config transforms.
# ...
msbuild /t:Rebuild /p:OutDir=..\$output_dir\ /p:Configuration=$build_configuration /p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False /p:TrackFileAccess=false "$web_app_project_file"
# ...
copy $output_dir\_PublishedWebsites\$web_app_project_name\* -destination $inetpub_dir -recurse -force
I'm using build in packaging from .net 4.0 and Web Deployment Tools on IIS. Here is a snippet of code to use it from PSake:
https://gist.github.com/579086
In Psake you have the function exec to run programs. With this task/function you can build, compile and publish your web app
You can execute asp_compiler to build you project/solution
Exec { aspnet_compiler.exe }
Refer to the msdn site for the exact syntax and parameters for the aspnet_compiler.exe
I have found an example that show how to do it :
http://blog.developwithpassion.com/2008/10/30/interested-in-trading-in-your-nant-builds-a-teaser/
精彩评论