In .csproj files you can use variables like $(SolutionDir). It's possible to find libraries that way.
How it's possible you can build .csproj by msbuild (not giving it solution path)? I can't see any sense in such behaviour, but it's working anyway.
Individual project files do not have awareness of what solution they are part of. Variables $(SolutionDir), $(SolutionPath), $(SolutionExt), etc, only defined when you build your .sln file, they are not defined when you build project directly.
To illustrate this, place this in your project file:
<Target Name="BeforeBuild">
<Message Text="SolutionDir=$(SolutionDir)" />
</Target>
When you build the solution you get this:
>msbuild sln.sln
Microsoft (R) Build Engine version 12.0.31101.0
...
BeforeBuild:
SolutionDir=e:\temp\sln\
...
When you build your project directly you get this:
>msbuild fs\fs.fsproj
Microsoft (R) Build Engine version 12.0.31101.0
...
BeforeBuild:
SolutionDir=*Undefined*
...
As you can see, $(SolutionDir) is badly broken. I don't recommend using it, along with other $(Solution***) variables, because you will want at some point to build project directly, or create new .sln file with different subset of your projects in other directory, and then you will run into build breaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With