tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Stopping MSBuild appending TargetFramework to OutputPath

4 Apr 2017 1 mins .NET Core, MSBuild, Visual Studio

If you’re using the new csproj format maybe you noticed that the OutputPath has the last part automatically appended according to the framework you’re targeting. For example targeting netstandard1.6 would result in build results to be in bin\[Debug|Release]\netstandard1.6, for net462 it would be bin\[Debug|Release]\net462. But what if you don’t like this behavior? What if you want to specify the path exactly?

Well, I needed the same. Sadly the framework part was always appended no matter what I did. Setting OutputPath explicitly. Using BaseOutputPath. Even using absolute path instead of relative didn’t help. So it was time to try luck grep-ing through the *.targets files, because it’s for sure something there. And hopefully can be disabled. It needs to be something with TargetFramework variable around OutputPath. Few attempts later I found AppendTargetFrameworkToOutputPath, which looked very promising. Quick test setting it to false and bingo. That’s what I need.

Therefore, if you’re ever in need to have your OutputPath exactly as you specified it, the AppendTargetFrameworkToOutputPath set to false is your answer.

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at www.tabsoverspaces.com.