How do I set `OutputPath` in a Visual Studio 2017 project (new .csproj file format) without the target framework cluttering the resolved path?

C#MsbuildVisual Studio-2017

C# Problem Overview


Setting OutputPath in the new Visual Studio 2017 project format automatically adds the target framework in the path. For example, if I have these set in the project file:

<TargetFramework>net462</TargetFramework>
<OutputPath>/build/debug/<OutputPath>

The actual output folder will resolve to /build/debug/net462/, not /build/debug/ like in the older versions. How do I solve this without workarounds like moving things around with post build actions?

C# Solutions


Solution 1 - C#

The solution is to use AppendTargetFrameworkToOutputPath https://www.tabsoverspaces.com/233608-stopping-msbuild-appending-targetframework-to-outputpath/

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

Solution 2 - C#

The answer above is right, but you may also want to remove the runtime identifier:

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionaksuView Question on Stackoverflow
Solution 1 - C#aksuView Answer on Stackoverflow
Solution 2 - C#JonView Answer on Stackoverflow