Dot Net Core Project Renaming Issue

Summary

I’m going to quickly demonstrate a bug that can occur in .Net Core and how to fix it quickly.  The error produced is:

The dependency LibraryName >= 1.0.0-* could not be resolved.

Where “LibraryName” is a project in your solution that you have another project linked to.

Setup

Create a new .Net Core project and add a library to it named “SampleLibrary”.  I named my soluion DotNetCoreIssue01.  Now add a .Net Core console project to the solution and name it “SampleConsole”.  Next, right-click on the “references” of the console application and add Reference.  Click the check box next to “SampleLibrary” and click the Ok button.  Now your project should build.

Next, rename your library to “SampleLibraryRenamed” and go into your project.json file for your console and change the dependencies to “SampleLibraryRenamed”.  Now rebuild.  The project is now broken.

Your project.json will look like this:

projectjson


And your Error List box will look like this:

errorlist



How To Fix This

First, you’ll need to close Visual Studio.  Then navigate to the src directory of your solution and rename the SampleLibrary directory to SampleLibraryRenamed.  

Next, you’ll need to edit the src file.  This fill is located in the root solution directory (same directory that the src directory is located.  It should be named “DotNetCoreIssue01.sln” if you named your solution the same name as I mentioned above.  Look for a line containing the directory that you just renamed.  It should look something like this (sorry for the word wrap):

Project(“{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}”) = “SampleLibraryRenamed”, “srcSampleLibrarySampleLibraryRenamed.xproj”, “{EEB3F210-4933-425F-8775-F702192E8988}”

As you can see the path to the SampleLibraryRenamed project is srcSampleLibrary which was just renamed.  Make that the same as the directory just changed: srcSampleLibraryRenamed

Now open your solution in Visual Studio and all will be well.

 

Leave a Reply