views:

619

answers:

3

Elsewhere on the Web, you can find recommendations on using something like this to simulate the Publish feature in the VS 2005-2008 IDE from a command-line (I hope I did not goof up the syntax!):

msbuild /t:ResolveReferences;_CopyWebApplication /p:BuildingProject=true;OutDir=C:\inetpub\wwwroot\ blah.csproj

Now, it looks like the .dll's copy fine. However, there are certain configuration files and template files that are copied to the bin folder which are needed for the app to work. For example, an NHibernate configuration file shows up in blah.csproj as:

<None Include="blah.cfg.xml">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

While using Publish from within the IDE copies this file as it should, the aforementioned _CopyWebApplication target does not. I need this file to be copied in the build script. Is this desired behavior for _CopyWebApplication? Any recommendations on how to fix this?

EDIT 4/21/2010:

Let me clarify that we are limited (for now) to VS 2005 and VS 2008 projects, and that our build scripts are written for MSBuild 3.x. We are not yet ready to move to VS 2010.

Let me also specify that we are looking for a solution available from within a command line so that we can automate a Publish-like command along with custom build options, and possibly automate deployments down the road.

A: 

Instead of calling those targets a better approach is to use Web Deployment Projects(2005 version). Using WDPs is very easy, and its much easier to customize the process versus what you are doing now. I highly encourage you to take a look at employing that solution.

Sayed Ibrahim Hashimi
Thanks for your reply. Unfortunately, "Web Deployment Project compile all the contents of the Web Application project, this includes all files regardless if they are added to your projects or not." -http://amiraryani.wordpress.com/2008/11/06/web-deployment-project-aspparse-could-not-load-type/. This behavior is one of the reasons why my team switched from VS Web sites to WAPs to begin with, so WDP's will not work, unless there is a _suitable_ workaround.
apollodude217
A: 

I was having a similar issue as well. I think the answer is using MSDeploy. Investigating it now, but may provide functionality required...

Bryce Fischer
Will this work with VS 2005 - 2008 projects? My team is not yet ready to switch anything over to VS 2010 or .NET 4, as we still have many applications still under VS 2005.
apollodude217
+1  A: 

This is just a workaround.

In the build script for publishing Web sites, after running MSBuild on the Web project itself to publish it (Targets="ResolveReferences;_CopyWebApplication"), I added a copy operation:

<Copy SourceFiles="@(ProjectBinFiles)" DestinationFolder="$(StageBin)\%(ProjectBinFiles.RecursiveDir)" />

where ProjectBinFiles is an Item representing the files in the bin directory in the source directory, and StageBin is a Property representing the bin folder in the published site's directory. So far, it seems to work.

apollodude217
I have tried this on multiple projects, and it seems to work well. :)
apollodude217