Search code examples
.netwarningscompiler-warnings.net-standard.net-standard-2.0

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)


Solution

  • 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'))" />