views:

488

answers:

2

I’ve been using mouse right click in Visual Studio to publish sites for ages and everything worked great except there’s been too much manual works. Recently I changed to using build script to call aspnet_compiler to publish ASP.NET web application. In my build script I would do something like below:

sh "#{aspnet_compiler} -p ../src/webapp -v targetDir ./publish –u"

My project directory structure looks like this:

/build/rakefile.rb
/build/publish/ --published site goes here
/src/website/bll/ --business logic goes here
/src/website/ --aspx pages
/src/website/code/ --some c# code

When calling aspnet-compiler everything worked fine except the c# code under /src/website/code/ would not be compiled. It seems to me that aspnet-compiler compiled c# code under bll directory then xcopied everything under /src/website/ to the publish directory (including /src/website/code/). I don’t know if I am not using the correct switch calling aspnet-compiler or this is the desired behaviour?

Please help thanks!

+1  A: 

I had similar problem when using aspnet_compiler on build machine (I used MSBuild). The solution for me was to build solution before calling aspnet_compiler. In MSBuild it looks something like:

<MSBuild Projects="$(PhysicalPath)\solutionName.sln" Properties="Configuration=Debug"/>

You can also use devenv solutionName.sln /build (if not using MSBuild).

BB
+1  A: 

I figured out my own problem.

First of all my rake build script end up looking like this:

sh "#{aspnet_compiler} -f -fixednames -u -p ../src/website -v / ./publish"

Second the output behaviour of mouse right click on "publish" within Visual Studio is different from calling aspnet_compiler.

Right click publish will:

  • directly copy Global.asax
  • only generate .dll and .pdb (.pdb file can be deleted if debugging is not required) files under bin directory

where when calling aspnet_compiler:

  • will compile Global.asax into App_global.asax.compiled and App_global.asax.dll under bin directory
  • will also generate PrecompiledApp.config (this is because I've specified aspx pages should be updatable)

There was a clean up task after publish task that basically deleted anything other than .dll extension under bin.

Anyway now I've learnt something new.

Jeffrey C
reference to aspnet_compiler http://msdn.microsoft.com/en-us/library/ms229863%28VS.80%29.aspx
Jeffrey C