Reputation: 598
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?
Upvotes: 4
Views: 5065
Reputation: 777
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
Upvotes: 0
Reputation: 10045
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.
Upvotes: 2
Reputation: 598
Nevermind, look like this was just some weird merge issue in TFS, was duplicating the lines.
Upvotes: 3