0

I'm trying to build a .NET Core project from the commandlind. The main project is a 'Web APi' which uses a library (CommonLib) that I've created as well. In VS2015 I've just added a reference to the library project and it builds fine here.

Now when I try to build the project using the command line, I start out running

dnu restore

It downloads all the nuget pacakages without any problems, but then I get the error:

Unable to locate Dependency CommonLib >= 1.0.0-*
Writing lock file C:\Local\WebApi1\src\WebApi1\project.lock.json
Restore complete, 3008ms elapsed

Errors in C:\Local\WebAPi1\src\WebApi1\project.json
    Unable to locate Dependency GRMCommon >= 1.0.0-*

I've tried to create add a NuGet.Config file in 'C:\Local\WebApi1\src\WebApi1' with the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="C:\Local\CommonLib\CommonLib" />
  </config>
  <disabledPackageSources>
    <add key="Microsoft and .NET" value="true" />
  </disabledPackageSources>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="aspnet-contrib" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />
  </packageSources>
  <activePackageSource>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </activePackageSource>
</configuration>

without any success

Not quite sure how to get this working...so any help would be greatly appreciated.

smolesen
  • 1,153
  • 3
  • 11
  • 29
  • Your CommonLib is a "Class Library (package)" project, that uses `net4xx` and/or `dotnet5x` monikers? When you compile this library it generates nuget packages for each target framework defined in it's project.json. You need your nuget feed to this output directory or build your class libraries into a common folder i.e. C:\nugetpackages\ and add this folder to your nuget feed and **not** your CommonLib project folder – Tseng Mar 30 '16 at 08:49
  • Ok, managed to get it to build...but do I really have to pack my libraries before I can use them in another project? – smolesen Mar 31 '16 at 07:56
  • Well, when you use Visual Studio 2015 all you need to do is to have your CommonLib (as Class Library (package)) and your application (Console Application (package) or ASP.NET 5 project) in the same solution and a "reference" (Right click references, Add, select project) your CommonLib from there. Dunno for console, but you'll likely have to make the folder containing the packages know to nuget / `dnu restore` / `dotnet restore`. Works only if you got both in the same solution though. If you have separate solution you need to put the packages in a common folder – Tseng Mar 31 '16 at 08:24
  • @smolesen: what exactly did you do to get it to build, i'm facing the same issue. Did you modify your NuGet.Config to somehow find the files locally? Thanks. – tntwyckoff Apr 26 '16 at 20:14
  • Yes, I had to create a nuget.config myself, took it from a setup with VS2015 installed. – smolesen Apr 26 '16 at 20:57

0 Answers0