Question

I try to build .csproj that references some projects in solution. These references are marked with CopyLocal=False. And this is the desired behavior.

I build it for CI using MSBuild, so I set output folder via /p:OutputPath="some output dir". I also set /p:SolutionDir="path to the solution" to correctly resolve some NuGet references.

The problem is: when I specify OutputPath with absolute path to the output directory (like d:\solution\build\buildgroupsubfolder), then MSBuild copies every dependency into output directory, I don't know why it is doing so. And if I specify output path with relative path (like ..\..\..\..\..\build\buildgroupsubfolder) then MSBuild correctly handles CopyLocal=false and doesn't copy references to output directory.

We had some nesting in our solution, projects are divided into groups, so we want them to be build into sub folders. And I want to be able to specify build path relative to base build path and not to path of project itself.

Why does MSBuild ignore CopyLocal=false when absolute path is specified and treats it correctly when relative path is specified?

Was it helpful?

Solution

Well, I've digged further. I've found out that MSBuild misbehaves, but not where I've though about it.

I've thought MSBuild had incorrect behavior as I described in my question. It really process CopyLocal=false as it should if I set OutputDir to relative path. And it misbehaves if I set OutputDir to absolute path. I found the answer in MSDN that says:

OutputPath - Specifies the path to the output directory, relative to the project directory, for example, "bin\Debug".

So in fact MSBuild should warn me or even fail when I set OutputPath to absolute path, but it doesn't. That's why I was under impression that absolute path is OK and there's a bug with CopyLocal handling. The actual bug is that MSBuild works when it should fail.

OTHER TIPS

I just had the same issue after switching my project and MSBuild from Visual Studio 2005 to Visual Studio 2010. However, I wanted to avoid having to use relative path, so instead I switched to using the new Web Publishing Pipeline (WPP) in .NET 4.0 by adding the following to my MSBuild command line:

/p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False

Now output is back to normal and still able to use absolute path in my output directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top