When running from Visual Studio, MSBuild is given the $(SolutionDir)
macro/property.
Running from Azure DevOps, this property does not exist (rightfully so).
Azure DevOps has the Build.SourceBranch
variable which can be passed to MsBuild as a property. This variable is better because it points directly to the repository root while $(SolutionDir)
may point to a sub-directory if the solution is not in the root.
Is there a consistent MsBuild property I can use in both Visual Studio and Azure DevOps which can point to the repository root?
One way to achieve this is to have a Directory.Build.props
file in the repository root and Specify a property <RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
however one restriction I have prevents me from doing this.