visual-studionugetnuget-spec

Creating a local NuGet feed


Basically I am trying to set up a Local NuGet feed on our network to pass out the dll's to other developers in the team. I have the NuGet feed working and can find my package and try and install it but I get many error all stating 'The type or namespace 'System' could not be found (are you missing a using directive or an assembly reference)?''

I've search SO and Google but only found a few vague references with very basic instructions such as :-

https://blogs.msdn.microsoft.com/mvpawardprogram/2016/06/28/creating-nuget-packages/

https://learn.microsoft.com/en-gb/nuget/hosting-packages/local-feeds

Does anyone know why I get this error or have a more detailed source for nuspec creation.

My nuspec file has the following dependencies

`<dependencies>
  <dependency id = "System" />
  <dependency id = "System.Collections.Generic" />
  <dependency id = "System.Threading.Tasks" />
  <dependency id = "System.Net" />
  <dependency id = "Newtonsoft.Json" />
  <dependency id = "SQLite.Net.Async-PCL" />
  <dependency id = "SQLite.Net.Core-PCL" />
  <dependency id = "Xamarin.Forms" />
  <dependency id = "Microsoft.Net.Htpp" />
  <dependency id = "Microsoft.Bcl.Build" />
  <dependency id = "Microsoft.Bcl" />
</dependencies>`

Solution

  • Does anyone know why I get this error or have a more detailed source for nuspec creation.

    According to the document: How NuGet resolves package dependencies

    Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends.

    So, when you install a NuGet package to the project with dependencies, NuGet will try to resolve its dependencies, then also install them into the project. In your nuspec file, you set system as dependency, NuGet will try to install this NuGet package system to your project. But this dependency is a assembly from .NET framework, which can not be resolved by NuGet. That`s the reason for the error "The type or namespace 'System' could not be found (are you missing a using directive or an assembly reference"

    To resolve this issue, you should remove the dependency of system or you may need to pack the assembly "system.dll" to a NuGet package and set it to your local NuGet feed.

    Besides, this issue may also occur on the dependencies "System.Collections.Generic", "System.Net", "Microsoft.Net.Htpp".