Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build with output folder causes assemblies to stomp on each other for Multiple TFMs

See original GitHub issue

Steps to reproduce

Create new net standard library. Set project file to be:

<Project Sdk="Microsoft.NET.Sdk">



open command line and run

dotnet build -o .\out

Extract the nupkg generated in the out folder In the extracted folder, open the lib\net46 folder and decompile the assembly that is in there.

Expected behavior

This assembly should have

[assembly: TargetFramework(“.NETFramework,Version=v4.6”, FrameworkDisplayName = “.NET Framework 4.6”)]

Actual behavior

instead it has:

[assembly: TargetFramework(“.NETStandard,Version=v2.0”, FrameworkDisplayName = “”)] Which results in similar errors as reported here: dotnet/standard/issues/542

The origin is most likely that the build step creates the 46 version first, then OVERWRITES the dll with the netstandard20 version and then packs that into both folders.

Environment data

C:\Program Files (x86)\Microsoft Visual Studio 14.0>dotnet --info .NET Command Line Tools (2.1.2)

Product Information: Version: 2.1.2 Commit SHA-1 hash: 5695315371

Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

Version : 2.0.3 Build : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

To be fair, this issue doesn’t occur when there is no output folder specified.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

Nirmal4Gcommented, Dec 9, 2020

Seems like -o is just broken for multi-targeting. It sets outputpath as a global property and that nullifies our appending of TFM. I think we need to change what -o passes to something like /p:OutputPathOverride=value and then we can build the real OutputPath from override + TFM.

@nguerrera My preferred solution would be that we map BaseOutputPath to -o instead of OutputPath for both legacy and Sdk-style projects. With BaseOutputPath (dotnet/msbuild#5238) support added to Common targets, we could just do that.

jimmyca15commented, Jul 10, 2020

I got hit by this today. I tried to see if I could include the TargetFramework into the output path but it didn’t work.

Something like dotnet build /p:OutDir=bin\shared\$(TargetFrameWork)"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Found multiple publish output files with the same relative ...
Issue: The issue raises after .NET 6 migration. There's a new feature that blocks multiple files from being copied to the same target ......
Read more >
MSBuild reference for .NET SDK projects
The assemblies referenced at build time will be copied into the ref subdirectory of the output directory. The names of the reference assemblies...
Read more >
How to stop references being copied to output directory ...
When using dotnet build on the My.Assembly project, the Private assemblies are always copied to the /external/ folder (resulting in multiple ...
Read more >
MSBuild + .NET Core CLI Tools: Getting information about ...
When installed, a user can invoked dotnet names and the tool will list the assembly name, root namespace, and names of target frameworks...
Read more >
Dotnet build configuration release. Other than the options ...
Go to the packages folder. View all page 2 Answers. Later, in a release step, I want to push all pre-release packages automatically,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found