NuGet.targets" cannot be imported again. It was already imported warning

I am getting this warning in Visual Studio 2013 for some of my projects:

NuGet.targets" cannot be imported again. It was already imported

My Main WCF project in the solution file has this:

Project("{FAE04EC0-301F-11D3-BF4B-01C04F79EFBC}") = "WCF.Project", "Website\WCF.Project.csproj", "{AEFE3DD8-6E77-4449-9632-E2F0BADB6EBC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{778ACFB4-FB04-4E26-93DD-260E7B406E48}"
    ProjectSection(SolutionItems) = preProject
        .nuget\NuGet.Config = .nuget\NuGet.Config
        .nuget\NuGet.exe = .nuget\NuGet.exe
        .nuget\NuGet.targets = .nuget\NuGet.targets
    EndProjectSection
EndProject

In my WCF project file it has:

<Import Project="$(SolutionDir).nuget\NuGet.targets" Condition="Exists('$(SolutionDir).nuget\NuGet.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir).nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nuget\NuGet.targets'))" />
  </Target>
  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />

Now that I look at it.. it looks like there is double in the for some reason?

Nevermind, look like this was just some weird merge issue in TFS, was duplicating the lines.

Migrate away from MSBuild-based NuGet package restore, targets file are created within a .nuget folder, and all projects that have NuGet package references will be modified to import the NuGet.targets file. Projects that use MSBuild-Integrated package restore typically contain a.nuget folder with three files: NuGet.config, nuget.exe, and NuGet.targets. The presence of a NuGet.targets file determines whether NuGet will continue to use the MSBuild-untegrated approach, so this file must be removed during the migration.

Despite this is an old question I got to it having exactly same error after migrating VS2015 solution to VS2017. Cleaning the NuGet cache solved this issue (see the picture).

HTH!

Edit: Problem re-appeared when building multiple projects. So, maybe a better approach is to move all sources to a new project with (possibly!) the same name, or at least same namespace/assembly name. Comparing converted/generated VS2015 and VS2017 .csproj files revealed a much more concise project structure in VS2017 even after downloading missing NuGets, not sure if it is worth editing each and every .csproj instead of replacing it with a newly generated one.

Setting file properties with NuGet using .targets file, I am not seeing the FrameworkTests.feature file get copied to the project when the package is installed. What do I need to change? This is the� MSBuild targets for Web and WebApplications that come with Visual Studio. Useful for build servers that do not have Visual Studio installed.

For others that maybe have this problem (like me) perhaps this will help:

(uninstall other VS or clean props folders)

VS Community - Nuget: targets and props warning about cannot be imported again

Bundling .NET build tools in NuGet, For this target, we will assume that a compiled version of our console tool will sit next to this targets file in this folder structure. +� Have you checked there's a.nuget directory in your solution's directory with the NuGet.targets file? The NuGet.targets is located using the $ (SolutionDir) variable, I can't see any other reason than the file not being there locally – Nock May 10 '12 at 12:00

Is it possible to import custom targets from a nuget package � Issue , I have created some custom targets for my csproj file and I'm loading it into my csproj file with an import tag. Could you also import from a nuget� Automatic import of msbuild targets and props files A new conventional folder has been created at the top level of the NuGet package. As a peer to \lib, \content, and \tools, you can now include a ‘\build’ folder in your package. Under this folder, you can place two files with fixed names, {packageid}.targets or {packageid}.props.

.props and .targets from build folder in NuGet package not imported , targets file actually do. Requested change: Could the Visual Studio NuGet extension automatically reload relevant projects after a package restore? The missing file is C:\Repos**\.nuget\NuGet.targets. I checked and nuget package restore is enabled. I closed and reopened visual studio, tried to build, opened nuget manager but it is not building and not restoring missing packages.

An Unusual NuGet.targets Build Error – thebeebs.net, NuGet.targets(119,5): error : The local source 'C:\Users\marti\source\repos\ AwsConsoleApp3\ClassLibrary1' doesn't exist� What is NuGet? NuGet is the package manager for .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.