1
votes

I am trying to create a nuget package for my library that has dependency on Unity. For that I placed below line in my nuspec file.

<dependencies>
  <dependency id="Unity" version="[3.5.0.0]" include="all" />
</dependencies>

and then executed below command

nuget pack MyClient.MyProject.ApplicationData.csproj -Prop Configuration=Release

When I use resulting package, at run-time I get error saying, "Could not load file or assembly 'Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

This question seems to be pointing to similar issue, referring it I copied nuget.config file as suggested in its referred link but that didn't helped. Content of nuget.config file are as below:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="packages" />
  </config>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

My project hierarchy is like this

MyClient  
--MyProject  
----MyProj.csproj  
----MyProj.nupkg  
--Packages  
----Unity.3.5.1404.0  
--NuGet.Config  

I got latest version of nuget with me and this is the first time I am creating a nuget package, could someone please suggest what I might be missing here. Any pointers?

Thanks,
Ravi

1

1 Answers

0
votes

I checked that "Unity, 3.5.0.0" package doesn't exists on nuget.org.v3(https://api.nuget.org/v3/index.json)

I have tried pack command with below nuspack file.

<dependency id="Unity" version="5.0.0" />

nuget.exe pack "D:\Test.Project.nuspec"

It created proper package with dependency.

These detail will help: What nuget version this project is using? Where is nuget reference mentions?

  1. In package.config and solution file (nuget version 2x)
  2. In Project.json (nuget version 3x)