Relative paths with MSBuild project vs solution
msbuild, visual-studio-2010
Solution
Well, I was able to find out what was causing this. That was custom .targets file, which was inferring SolutionDir property at the start of any msbuild. I did find out that by using MSBuild Explorer. The tool proved to be very useful in my case - I was not aware of third party .target files on my system.
Problem
I have a number of projects which are joined into a solution. Every project has it's own directory structure, and csproj files are located on diferrent level of folder structure. Every csproj has OutputPath property specified. OutputPath - is a relative path and it varies from project to project in such a way so all projects have the same output dir. It is work OK if I build a separate project. But everything changes if I try to build solution file. In this case every project output folder differs (depends on a number of '..\' in that project's OutputPath). I do know, that before some moment all was working fine. Nobody changed build.cmd neither any sln or csproj files. But now I have situation described above. So my question is - what affects how relative path is evaluated? I mean how can I force relative OutputPath to be evaluated starting from folder where csproj file of that particular project is located. Not from folder where .sln file is. ``` Let's assume I have following directory structure: dir1 a.sln dir2 a.csproj dir21 dir3 b.csproj ``` a.csproj has output path set to '../../_bin' which is just above dir1 if counted from a.csproj folder b.csproj has output path set to '../../../_bin' which is same - just about dir1 if counted from b.csproj a.sln contains both - a.csproj and b.csproj. When I run msbuild I get a project build to 'dir1/../../_bin' and b project to 'dir1/../../../_bin' - both relative paths of projects files are counted from solution file location, not project files.