1

I'd like to have a web project in a solution that is set to "not build" in the solution configuration, however I would still like the project's references (and their dependencies) to be copied into that project's bin folder. There are class library projects in the sln that are actually built, and the web project references those.

Our current "build" just calls devenv, which does exactly this. For obvious reasons, I'd rather use MSBuild.

I am not looking for methods to do manual file copying (either individually or *.dll). There are many ways to do this. I am looking specifically for a way to replicate the behaviour that devenv.exe gives us - automatically copy references (and their dependencies) based on what is in the project section in the solution file (below).

These references come from the solution in this section:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}")="TheWebProjectName", 
                                                  "Web\Project\Folder", 
                                                  "{1CBD1906-0C2E-4C92-A81D-63C2AD816EA1}"
    ProjectSection(WebsiteProperties) = preProject
        TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
        ProjectReferences = "{B125568E-E80C-4080-B8D3-5602B604734C}|Some.Reference.dll;
                             {117E8B0A-F0D6-47D0-BB51-71099969566D}|Some.OtherRef.dll;"
        ...
    EndProjectSection
EndProject
csauve
  • 5,904
  • 9
  • 40
  • 50
  • Consider [`MSDeploy sync`](http://technet.microsoft.com/en-us/library/dd569005(WS.10).aspx) – KMoraz Apr 11 '12 at 09:14
  • Thank you for the comment, but I'm not sure that's what I'm looking for. I need to first get the web project's references into that project's bin folder before I can sync those to another web server. – csauve Apr 11 '12 at 16:04

4 Answers4

2

MSBuild uses target files to determine it's build steps. Take a look at the relevant target files and determine how MSBuild copies those files, create your own target file and modify your build configuration to use the new target.

Relevant target files:

  • Location: C:\Windows\Microsoft.NET\Framework\v$(version)
  • Microsoft.CSharp.targets
  • Microsoft.Common.targets

Relevant documentation:

Community
  • 1
  • 1
Dan Busha
  • 3,723
  • 28
  • 36
  • Okay thanks I'll have a look. You get the bounty (even though I'm not sure if that will actually solve it, but you are the only one that seems to have read the question) – csauve Apr 20 '12 at 16:33
1

You can do build operations such as this using MSBuild Tasks: http://msdn.microsoft.com/en-us/library/ms171466(v=vs.80).aspx

In your specific case you'll probably be interested in the built in Copy Task: http://msdn.microsoft.com/en-us/library/3e54c37h(v=vs.80).aspx

KodeKreachor
  • 8,852
  • 10
  • 47
  • 64
  • If I do that I have to specify every file I would like to copy. We have about 50 class libraries and about 10 web projects. Also, references would need to be updating in our msbuild project every time they changed in the web projects. I want the same functionality that calling devenv gives me. (if i wanted to do just file copies there are over 9000 ways to do that) – csauve Apr 13 '12 at 18:27
  • Fair enough I suppose, although your original question only mentioned copying refs from "a web project in a solution" Failed to mention 50 class libraries and 10 web projects and that you're not looking for file copy operations. You obviously edited your initial question after my answer. Make your intentions clear before posting the question and you'll have a better chance at getting the answers you're after. – KodeKreachor Apr 13 '12 at 20:24
  • I figured it was implicit that people don't go to SO to ask questions about "how to I copy file A to location B". – csauve Apr 13 '12 at 22:24
  • 3
    *sigh*...you figured wrong, SO isn't reserved for elitists, people of all levels of knowledge and skill visit this great site to learn and share what they know – KodeKreachor Apr 13 '12 at 22:43
-1

Try using powershell instead of msbuild!! Ria services also relies strongly on powershell commandlets.

Cheers..

Equalizer
  • 34
  • 3
  • Your comment doesn't do much in the way of solving this problem without specifying which command in powershell to use. Please be more specific. – csauve Apr 17 '12 at 03:41
-1

Call devenv.exe using an Exec task - we do it all the time for BizTalk solutions because old versions of MSBuild do not support the BizTalk project files...

Fabio
  • 730
  • 3
  • 10
  • That does not put me any further ahead. All that would do is wrap devenv in msbuild, accomplishing nothing. – csauve Apr 18 '12 at 22:44
  • Maybe I don't understand your question - but if you want the exact functionality that devenv provides, how does wrapping devenv accomplish nothing? – Fabio Apr 19 '12 at 10:56
  • I want the functionality that devenv provides, without using devenv. I would like to accomplish the same thing using MSBuild. – csauve Apr 19 '12 at 18:01
  • I would like to use MSBuild for several reasons - its faster, it allows more customization (custom targets etc), and allows multiprocessor. A build of our solution using MSBuild takes about 1/20th the time as with devenv (30seconds vs 6 minutes) - the only piece missing is that these web project references are not copied. – csauve Apr 19 '12 at 18:04