13

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.

Alex Peck
  • 4,603
  • 1
  • 33
  • 37
jyoungdev
  • 2,674
  • 4
  • 26
  • 36
  • Odd, I had the same problem and adding ResolveReferences prior to _CopyWebApplication fixed it for me. Are you sure you have CopyLocal set to True on all your references? – Allen Rice Aug 10 '10 at 14:49
  • 1
    Might want to check out this bug http://connect.microsoft.com/VisualStudio/feedback/details/383199/resolvereferences-does-not-correctly-walk-all-references-in-dependent-projects – Allen Rice Aug 10 '10 at 16:44
  • @Allen - I did not look at CopyLocal. I will read up on that. – jyoungdev Aug 10 '10 at 21:10

3 Answers3

6

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.

jyoungdev
  • 2,674
  • 4
  • 26
  • 36
0

I had this same issue in VS 2012 and eventually fixed it by doing the following to any files which needed to be copied:

  • Set the Copy to Output file property to Copy if newer
  • Set the Build Action file property to Content (or Compile if the file needs to be compiled)
laurie
  • 708
  • 6
  • 16
0

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
  • 5,336
  • 9
  • 30
  • 36
  • 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. – jyoungdev Apr 21 '10 at 18:13