Reputation: 1064
When trying to build asp.net core project after changing the project path to the solution. I got the following compilation error in my solution referring visual studio file at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets"
Error: An item with the same key has already been added. Key: Data Namespace.ProjectName C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 241
https://drive.google.com/file/d/0B8pVTUXkCFSpdWNpNHN5Y01CRnM/view?usp=sharing
Upvotes: 3
Views: 2062
Reputation: 4051
None of the previous answer worked for me, here is what did the trick:
project.lock.json
(not always required)dotnet restore --no-cache
dotnet build
(a build in VS at this point still failed but works on command lineAfter that, it should build fine in VS.
BTW, if you are using TFS, don't forget to add an *.lock.json
entry to your .tfignore
file.
Upvotes: 1
Reputation: 5010
A dotnet restore --no-cache
can also work. The Visual Studio 2015 tooling is not fully baked yet so you will run into these problems from time to time. I usually run into them when I make major changes to project.json.
Upvotes: 5
Reputation: 1064
Delete "project.lock.json" file from project files and rebuild the project again
Upvotes: 13