How to publish web site using PSAKE
Asked Answered
B

3

7

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

Bermejo answered 22/1, 2011 at 13:52 Comment(0)
B
3

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/

Bacterium answered 24/1, 2011 at 22:41 Comment(1)
aspnet_compiler has issues with compiling folder, not project file. But this is not an issue, but a reason to clean up projectBermejo
B
5

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
Borderer answered 8/4, 2012 at 23:49 Comment(0)
C
4

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

Coreencorel answered 8/2, 2011 at 9:14 Comment(0)
B
3

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/

Bacterium answered 24/1, 2011 at 22:41 Comment(1)
aspnet_compiler has issues with compiling folder, not project file. But this is not an issue, but a reason to clean up projectBermejo

© 2022 - 2024 — McMap. All rights reserved.