MSBuild copies dependencies when an absolute path is specified, and ignores when relative

I am trying to build a .csproj that references some projects in a solution. These links are marked CopyLocal=False . And this is the desired behavior.

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

The problem is this: when I specify OutputPath with an absolute path to the output directory (for example, d:\solution\build\buildgroupsubfolder ), then MSBuild copies each dependency to the output directory, I don't know why this is done. And if I specify the output path with a relative path (for example ..\..\..\..\..\build\buildgroupsubfolder ), then MSBuild correctly processes CopyLocal=False and does not copy the links to the output directory.

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

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

+4
source share
2 answers

Well, I dug up even more. I found that MSBuild is mistaken, but not where I have it.

I thought MSBuild had the wrong behavior, as I described in my question. It really handles CopyLocal=false , as it should, if I set OutputDir to a relative path. And this is wrong if I set OutputDir to an absolute path. I found the answer on MSDN that says:

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

So MSBuild should warn me or even crash if I set OutputPath to an absolute path, but it is not. That's why I got the impression that the absolute path is ok and there is an error processing CopyLocal . The actual error is that MSBuild works when it does not work.

+4
source

I had the same problem after switching my project and MSBuild from Visual Studio 2005 to Visual Studio 2010. However, I didn't want to use the relative path, so instead I switched to using the new web publishing (WPP) in .NET 4.0, adding the following to my MSBuild command line:

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

Now the output returns to its normal state and can still use the absolute path in my output directory.

0
source

Source: https://habr.com/ru/post/1435831/


All Articles