Sdk: Duplicate Targetframework attribute

Created on 29 Sep 2018  路  8Comments  路  Source: dotnet/sdk

I have similary problems with that issue.
It started when i run npm install. Packages installation finished with error then dotnet build got error
I tried deleting the obj and use dotnet clean. It is not helped me.

Steps to reproduce

npm install
dotnet build

Expected behavior

Successful build

Actual behavior

/tmp/.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [/root/betprofit-server/VFL.Web/VFL.Web.csproj]

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.402
 Commit:    3599f217f4

Runtime Environment:
 OS Name:     debian
 OS Version:  8
 OS Platform: Linux
 RID:         debian.8-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.402/

Host (useful for support):
  Version: 2.1.4
  Commit:  85255dde3e

.NET Core SDKs installed:
  2.1.2 [/usr/share/dotnet/sdk]
  2.1.402 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Most helpful comment

I am not sure why npm install would interfere with this at all. Do you have any customization in your project that might be causing this?

Could you share with us a binlog? dotnet build /bl, should generate a .binlog file that you could share with us. Do notice that if you do, the binlog logs secrets and things like that, so make sure you don't have any in your build before sharing.

Without a binlog or a repro we can reproduce ourselves, there isn't much we can do.

You can try setting <GenerateAssemblyInfo>false</GenerateAssemblyInfo> in your project, so see if the file stops being generated and your build succeeds.

All 8 comments

Please, provide us with more details. What kind of project are you creating? Can you give us a full repro for this? The issue you referenced has been closed for months. Please provide either a repo on github where we can repro this or detailed repro steps. The steps you provided above are not sufficient.

My project very old. The project was successfully compiled before use npm install.
I notice that in project root folder create autogenerate file .NETCoreApp,Version=v2.1.AssemblyAttributes.cs. If I delete it the compilation is successful but then created again

Cat .NETCoreApp,Version=v2.1.AssemblyAttributes.cs

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v2.1", FrameworkDisplayName = "")]

I am not sure why npm install would interfere with this at all. Do you have any customization in your project that might be causing this?

Could you share with us a binlog? dotnet build /bl, should generate a .binlog file that you could share with us. Do notice that if you do, the binlog logs secrets and things like that, so make sure you don't have any in your build before sharing.

Without a binlog or a repro we can reproduce ourselves, there isn't much we can do.

You can try setting <GenerateAssemblyInfo>false</GenerateAssemblyInfo> in your project, so see if the file stops being generated and your build succeeds.

No, i think that no. Before the advent of have this error i added one new npm package in my project.

Okay, can I leave a direct link here?

Without a binlog or a repro we can reproduce ourselves, there isn't much we can do.

Yes, this help me

You can try setting false in your project, so see if the file stops being generated and your build succeeds.

Yes, you can leave a link here.

So, setting the property above fixed the issue for you?

Yes, it helped

LOL! After setting the property and next successful build. I try remove the property but dotnet build again successful. It is MAGIC! Yesterday, i ran three times dotnet build then every time i had to delete assembly generate file.

I am going to close this issue then. Thanks.

Was this page helpful?
0 / 5 - 0 ratings