Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish web site using PSAKE

Is there a way to publish asp.net web application using PSAKE, just like visual studio do?

like image 445
AlfeG Avatar asked Jan 22 '11 13:01

AlfeG


3 Answers

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
like image 70
ngm Avatar answered Nov 09 '22 00:11

ngm


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

like image 20
Aleš Roubíček Avatar answered Nov 09 '22 02:11

Aleš Roubíček


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/

like image 3
jboo Avatar answered Nov 09 '22 01:11

jboo