9
votes

I have a NuGet .nuspec that looks like this:

    <?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
    <metadata>
        <id>XXXXXXXXX</id>
        <version>1.0.0-alpha</version>
        <authors>XXXXXXXXX</authors>
        <owners>XXXXXXXXXXX</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>XXXXXXXXXXXXXXXXXXX</description>
        <copyright>XXXXX</copyright>
        <dependencies>
            <group>
                <dependency id="Dependency1" version="1.0.0" />
            </group>
            <group targetFramework=".NETFramework3.5">
                <dependency id="Dependency2" version="3.9.71" />
            </group>
            <group targetFramework=".NETFramework4.0">
                <dependency id="Dependency3" version="4.0.30" />
                <dependency id="Dependency4" version="4.0.30" />
                <dependency id="Dependency5" version="4.0.30" />
                <dependency id="Dependency6" version="4.0.30" />
            </group>
        </dependencies>
    </metadata>
    <files>
        <file src=".XXX.Net35\bin\Release\XXX.dll" target="lib\net35" />
    </files>
</package>

When I package the NuGet package with the nuspec via:

nuget pack XXXXXX.nuspec

Everything is good, the dependency groups are all there. If I package with the csproj like:

nuget pack XXXXXX.csproj

The dependencies are all lumped into one target rather than in groups. I really want the functionality of using the $id$ and $version$ variables with the ability to do dependency groups based on target framework.

Anyone know of a solution?

1

1 Answers

1
votes

Make sure that you go to the directory that has your .csproj file and execute nuget spec to create a .nuspec file based on your .csproj. Investigate it and make sure it looks as you want, customize it for various target frameworks, then nuget pack XXXXXX.csproj to have it build and respect the .nuspec.