I have been playing around with a few MSBuild properties inside a Directory.Builds.props of which the latest is changing location of obj/bin folders. By default the project output is put inside of sdk / TargetFramework version folder e.g. proj/bin/Debug/net8.0/
When the <OutDir> property is used to set custom directory the sdk version is not included. I have looked at the ms docs for a variable but couldn’t find one that worked. I have also looked into reading the .csproj file as well but I have had issues finding a solution for getting a specific xml value from the file e.g. TargetFramework. A lot of the docs that pop up are very old as well and I’d prefer not going there if there is a simpler solution.
Example Directory.Build.props file:
<Project>
<PropertyGroup>
<OutDir>$(SolutionDir)/builds/$(MSBuildProjectName)/bin/$(Configuration)</OutDir>
...
</PropertyGroup>
</Project>
Example console project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
Example output dir of above would be:
solution/builds/proj/bin/debug/
What I’d like to have with version:
solution/builds/proj/bin/debug/net8.0
How to get the sdk / TargetFramework version?