I'm trying to create a package that contains dependencies which should include Build and Analyzer assets into the installed project. However, the generated nuspec always generates dependencies from package and project references as:
<dependency id="packageid" version="version" exclude="Build,Analyzers" />
Is there a way to alter this? I would have expected something like this to work:
    <ProjectReference Include="..\otherpackage\otherpackage.csproj">
        <IncludeAssets>All</IncludeAssets>
    </ProjectReference>
    <PackageReference Include="SomePackage" Version="version">
        <IncludeAssets>All</IncludeAssets>
    </PackageReference>
Workaround:
Use <NuspecFile> and <NuspecProperties> and manually list the dependnecies using the right 'exclude' setting.
cc @rohit21agrawal
IncludeAssets/PrivateAssets/ExcludeAssets should flow the right Exclude strings in the nuspec, if it's not doing it it's a bug. Repro project?
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.0">
      <IncludeAssets>All</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>
dotnet restore
dotnet msbuild /t:GenerateNuspec
Nuspec file contains:
      <group targetFramework=".NETCoreApp1.0">
        <dependency id="Microsoft.NETCore.App" version="1.1.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.Extensions.Configuration.UserSecrets" version="1.1.0" exclude="Build,Analyzers" />
      </group>
Using CLI 1.0.0-rc4-004757
Try PrivateAssets None. Build/Analyzers are excluded as part of PrivateAssets by default. When creating a nuspec there is no concept of PrivateAssets, so they get added to the Include/Exclude lists. This isn't very intuitive however.
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.0">
      <PrivateAssets>None</PrivateAssets>
    </PackageReference>
Just checked. Setting PrivateAssets=None works. It generates include="all" on dependencies.
@natemcmaster here is the test matrix, in case you need to see the various combinations :
https://github.com/NuGet/NuGet.Client/blob/dev/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs#L175-L187
here is the test matrix, in case you need to see the various combinations
Here's a link to a specific commit, so that the line numbers don't go out of sync with the code: https://github.com/NuGet/NuGet.Client/blob/8d300225298df9c6af6c784efffa7522109f0096/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs#L379-L391
Most helpful comment
Try PrivateAssets None. Build/Analyzers are excluded as part of PrivateAssets by default. When creating a nuspec there is no concept of PrivateAssets, so they get added to the Include/Exclude lists. This isn't very intuitive however.