I believe the problem is documented here moved here and looks like it might be a bug in visual studio, but I\'m wondering if anyone knows of a workaround.>
Wasted a lot of time to find perfect solution for this problem. Use Directory.Build.props.
In your sln location folder create a file with name Directory.Build.props and put this code inside:
$(MSBuildThisFileDirectory)
This file will be automagically picked up by all your csproj files and will define (SolutionDir) property.