Sdk: Is there a way to disable <OutputPath> replacement?

Created on 26 Dec 2016  路  4Comments  路  Source: dotnet/sdk

I'm attempting to use the new project system on a MVC5 application:

The problem is that MVC5 applications expect for \bin to be \bin, not \bin\$(TargetFramework). Unfortunately, Microsoft.NET.TargetFrameworkInference.targets unconditionally appends the target framework here: Microsoft.NET.TargetFrameworkInference.targets#L95

  <PropertyGroup>
    <IntermediateOutputPath>$(IntermediateOutputPath)$(TargetFramework)\</IntermediateOutputPath>
    <OutputPath>$(OutputPath)$(TargetFramework)\</OutputPath>
  </PropertyGroup>

Is there any way to opt out of this behavior? It's definitely not desirable in some situations and breaks an otherwise mostly-working project system for people migrating. There are many benefits of a simpler .csproj (fewer 3-way merges and reloads alone) even before people migrate to .NET Core, etc. So I'd love to see this work.

Bug

Most helpful comment

This was fixed by #811, which now allows you to set <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> in your project.

All 4 comments

For anyone else hitting this, I'm temporarily using this workaround:

<PropertyGroup>
  <PostBuildEvent>
  start xcopy /s /y "$(MSBuildProjectDirectory)\bin\net462\*.*" "$(MSBuildProjectDirectory)\bin"
  </PostBuildEvent>
</PropertyGroup>

The new workaround for this is a Directory.build.targets file instead of a copy:

<Project>
     <PropertyGroup>
         <OutputPath>bin/</OutputPath>
         <OutDir>bin/</OutDir>
     </PropertyGroup>
 </Project> 

While OutDir affects most things, OutputPath is needed for the main project's PDB, e.g. Samples.Mvc5.pdb.

This was fixed by #811, which now allows you to set <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> in your project.

@nguerrera Thanks, the new property is working great!

Was this page helpful?
0 / 5 - 0 ratings