How can I keep NuGet from including dependent binaries?

92 Views Asked by At

I have a project that depends on another nuget package that drops native binaries into the bin directory of my project.

I need to create a Nuget spec to package up my binaries. The simple method

<package>
    <metadata>
        <id>MY ID</id>
        <version>$version$</version>
        <title>MY TITLE</title>
        <authors>ME</authors>
        <owners>ME</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>MY DESC</description>
        <releaseNotes>Internal Version</releaseNotes>
        <copyright>Copyright 2018</copyright>
        <dependencies>
            <dependency id="foo" version="3.0.6" exclude="all"/>
            <dependency id="bar" version="3.0.6" exclude="all"/>
            <dependency id="baz" version="3.0.6.101" exclude="all"/>
            <dependency id="gronk" version="11.0.2" exclude="all" />
        </dependencies>
    </metadata>
</package>

results in a huge nupkg with lots of dependent binaries present, along with a pile of warnings:

WARNING: Issue: Assembly outside lib folder.

An empty files element suppresses the bins, but I really need some files (namely, a readme.md and some samples) in the package as well.

When I add the following to the nuspec:

<files>
    <file src=".\Content\EventsHelpers.cs" target="content\Helpers" />
    <file src=".\Readme.md" target="content" />
</files>

I get the content I need, but I then get the (large) files from the dependent binaries.

How can I get the files I want while suppressing the dependent binaries?

EDIT: I can do this via the command line, however, the CI pipeline I'm using doesn't let me set the command line. So I need to do it via the nuspec.

0

There are 0 best solutions below