BRBdot
BRBdot

Reputation: 808

Warning: .NETStandard.2.0.0.0 Library cannot be imported again

I'm getting this annoying warning message.

"{your path}\packages\NETStandard.Library.2.0.0\build\NETStandard.Library.targets" cannot be imported again. It was already imported at "{your project path}". This is most likely a build authoring error. This subsequent import will be ignored. Data...(See my own answer below)

Upvotes: 1

Views: 2399

Answers (2)

BRBdot
BRBdot

Reputation: 808

After researching my code I finally figured out why VS shows a warning. In the Error list next to the warning look for the Project Name. Unload the project and edit the .csproj file and look for the below references. You'll notice that there are multiple rows with slight variations. Delete these ones and leave the other untouched. Save and reload and the warnings disappeared.

<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.0\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.0\build\NETStandard.Library.targets'))" />

<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.0\build\netstandard2.0\NETStandard.Library.targets'))" />

Upvotes: 4

wonster
wonster

Reputation: 746

Here is the warning message I was getting in Visual Studio 2017

Warning "C:[your_path]\.nuget\packages\netstandard.library.netframework\2.0.0-preview2-25405-01\build\NETStandard.Library.NETFramework.common.targets" cannot be imported again. It was already imported at "C:[your_path_2\.nuget\packages\netstandard.library.netframework\2.0.0-preview2-25405-01\build\net461\NETStandard.Library.NETFramework.targets (10,3)". This is most likely a build authoring error. This subsequent import will be ignored.

I was referencing a pre-release version of NETStandard. Replacing with the latest stable version using NuGet manager has resolved the issue.

Before

<PackageReference Include="NETStandard.Library.NETFramework" Version="2.0.0-preview2-25405-01" />

After

<PackageReference Include="NETStandard.Library" Version="2.0.1" />

Upvotes: 1

Related Questions