*.targets cannot be imported again. It was already imported

microsoft.csharp.targets cannot be imported again. it was already imported at
microsoft webapplication targets cannot be imported again
microsoft web importafter targets was not imported

I have UWP app build in VS 2017 and many project in my solution have build warning like below. How to get rid of them?

Warning "C:\Program Files (x86)\MSBuild\15.0.Net\CoreRuntime\Microsoft.Net.CoreRuntime.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.Net.CoreRuntime.ImportAfter.targets (17,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\Controllers\HA4IoT.Controller\HA4IoT.Service.csproj] HA4IoT.Tests Warning "C:\Program Files (x86)\MSBuild\15.0.Net\CoreRuntime\Microsoft.Net.CoreRuntime.Settings.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\Microsoft.Net.CoreRuntime.ImportBefore.targets (17,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\DNF\HA4IoT.Extensions.Tests\HA4IoT.Extensions.Tests.csproj] HA4IoT.Controller.Dnf Warning "C:\Users\dnf.nuget\packages\microsoft.net.native.compiler\1.6.3\tools\Microsoft.NetNative.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.NetNative.ImportAfter.targets (16,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\Controllers\Examples\HA4IoT.Controller.Main\HA4IoT.Controller.Main.csproj] HA4IoT.Controller.Main

How to get rid of them?

I found the work-around of this question on MSDN:

Using condition to check the existence of a unique property defined in the considering project file.

<PropertyGroup>
  <TasksTargetsImported>true</TasksTargetsImpor‌​ted>
</PropertyGroup>

<Import Project="Tasks.targets" Condition=" '$(TasksTargetsImported)' == '' "/> 

Hope this can helps.

*.targets cannot be imported again. It was already imported, Net\CoreRuntime\Microsoft.Net.CoreRuntime.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft  Nuget: targets and props warning about cannot be imported again windows 6.3 visual studio 2017 version 15.3 Terje Sandstrom (AAD) reported Sep 08, 2017 at 04:50 PM

I removed all nuget target and prop files next to the .csproj files. This worked for me. All warnings are now gone.

MSB4011, Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.​targets" cannot be imported again. It was already imported at "D:\Program Files  There is no need to specify an SDK at the project-element level in a .props or .targets file. The Sdk="Microsoft.NET.Sdk" attribute is a shorthand way of specifying an import at the top and bottom of the project file, which used to be explicit <Import elements.

I had the error "\PrefixFidelity\obj\PrefixFidelity.csproj.nuget.g.props(16,5): warning MSB4011: "..."This is most likely a build authoring error. This subsequent import will be ignored."

trace it to a second props file in the obj folder: PrefixFidelity.csproj.nuget.g.(2)props

once that file was deleted the error was gone

*.targets cannot be imported again. It was already imported, Settings.targets" cannot be imported again. It was already imported at "C:\​Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\​Microsoft. Do you have any customization in your project? Something that is overriding TargetFrameworkIdentifier and setting it to .NetCoreApp? I tried a csproj exactly like you have above (without the import) and it builds successfully for me.

I got this issue using the CLI tools after updating VS2017,

The fix was to simply delete the bin/obj folders, not modifying the targets file

the work-around of this question on MSDN - TechNet, It was already imported at "D:\Program Files (x86)\Microsoft Visual Studio\2017\​Enterprise\MSBuild\15.0\Imports\Microsoft.Common.props\ImportBefore\Microsoft​  Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

Nuget: targets and props warning about cannot be imported again , props" cannot be imported again. It was already imported at "E:\!Sitefinity\Projects​\SubZero\SitefinityWebApp.csproj (3,3)" . This  The Microsoft.WebApplication.targets file in turn imports the Microsoft.Web.Publishing.targets file. The Microsoft.Web.Publishing.targets file essentially is the WPP. It defines targets, like Package and MSDeployPublish, that invoke Web Deploy to complete various deployment tasks.

Bug: SitefinityWebApp.csproj contains multiple "Import Project" lines , Makefile.props" cannot be imported again. It was already imported at "C:\Program Files (x86)\MSBuild\Microsoft. Importing a target/props file multiple times causes a MSB4011 warning. The only mechanism to avoid it is to condition the import to happen only when some property is empty. This places the burden on the importer, and cannot be done for transitive imports.

[4.17.2] Visual Studio compiles but with warning: warning MSB4011 , I am randomly (!) getting this exception and would like to know how to debug it: 4​>C:\Users\User\Projects\MyProject\MyProject.csproj(890,3):  NuGet outputs a bunch of warnings about duplicate imports during about duplicate imports during restore qfp.targets" cannot be imported again. It was already

Comments
  • Are you running the last version of VS 2017 e.g. 15.3 or 15.4 if preview? AFAIK this issue has been resolved before RTM. Also you may try repairing VS.
  • I have done clean and rebuild on both VS 2017 15.3.3 and 15.4, also done clean instal of 15.3.3 but warnings are still there
  • This is because of the cs file created in older version and then migrated to VS 2017. I had the same issue. All i did was create a new Solution in VS 2017, add nuget packages and edit the cs file to match the new cs file created in vs 2017. Pretty hacky but does the job.
  • I think you are talking about csproj not cs? I'm not sure what you were aditing in those file? You have added new projects and move files to them or update something specific in old files?
  • why is that working and what are those files for?
  • I got the warnings after updating the Target and Min Versions, so my guess is that the .target and .prop files once had to be in the project, but got factored out later on into the build system.
  • Welcome to Stackoverflow! Please format your post to make it more readable (Bold, italic, list , code indentation etc)