简体   繁体   中英

Createing reference with NuGet in Azure Devops

I create a NuGet package and publish it to a feed in Azure Devops.

When consuming it a dependent dll wasen't included, it dosen't exist as a NuGet package so i can't fix it like that.

i changed the csproj and added it like described here .

Now i get the dll, but not added as a Reference. Is that possible to fix in Azure Devops?

Since you packedd the dependent dll with your NuGet package. When the NuGet package is consumed by your project, the dependent dll will exist in ..\packages\{yourNugetPackage}\lib\{targetFramework}\dependent.dll .

So you can manually add a Reference in your project to this dependent dll. For below example.

<ItemGroup>
    <Reference Include="DependentDll">
          <HintPath>..\packages\yourNugetPackage.1.0.0\lib\netcoreapp2.0\dependent.dll</HintPath>
    </Reference>
</ItemGroup>

Another possible workaround is that you can try creating another Nuget package for this dependent dll and publish it to the feed in azure devops.

Then add dependency to this package in your original Nuget package project and republish to feed in Azure Devops.So that the dependent dll can be managed with your original Nuget Package. See below simple example.

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>sample</id>
        <version>1.0.0</version>
        <authors>Microsoft</authors>
        <dependencies>
            <dependency id="dependentDllPackage" version="1.0.0" />
         </dependencies>
    </metadata>
</package>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM