dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

Pack without explicit NETStandard.Library dependency #3490

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago

Repro steps:

  1. New project:

    <Project Sdk="Microsoft.NET.Sdk">
    
    <PropertyGroup>
    <TargetFramework>netstandard1.3</TargetFramework>
    </PropertyGroup>
    
    <PropertyGroup>
    <Version>0.1.0-dev</Version>
    <Authors>Author</Authors>
    <Description>Descriptor</Description>
    <NeutralLanguage>en</NeutralLanguage>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <PackageLicenseExpression>MIT</PackageLicenseExpression>
    </PropertyGroup>
    
    <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.1" PrivateAssets="none"/>
    <PackageReference Update="NETStandard.Library" PrivateAssets="all" />
    </ItemGroup>
    </Project>
  2. Build in VS

  3. Inspect package:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>PackRepro</id>
    <version>0.1.0-dev</version>
    <authors>Author</authors>
    <owners>Author</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <description>Descriptor</description>
    <dependencies>
      <group targetFramework=".NETStandard1.3">
        <dependency id="Microsoft.CodeAnalysis.CSharp" version="2.3.1" exclude="Build,Analyzers" />
        <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
</package>
livarcocc commented 5 years ago

@JohanLarsson what is your expectation for this scenario?

JohanLarsson commented 5 years ago

I'm trying to pack without <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" /> in created package. From what I read <PackageReference Update="NETStandard.Library" PrivateAssets="all" /> is meant for that use case.

jnm2 commented 5 years ago

<PackageReference Update="NETStandard.Library" PrivateAssets="all" /> was what I asked about in https://github.com/dotnet/standard/issues/601 for .NET Standard 1.x projects in order to forgo supporting VS2015-no-build-extensions and suppress the <dependency> element.

I remember it working at one point.

nguerrera commented 5 years ago

This is likely caused by having moved the implict references to a CollectPackageReferences target. @dsplaisted. I think the workaround would now have to include a target, and it gets messy as Update doesn't work in targets and you have to use a harder to read Condition. :( Maybe we should have a property for this.

dsplaisted commented 5 years ago

I'm not able to repro this with preview 8 (3.0.100-preview8-013651). The implicit PackageReferences for NETStandard.Library and Microsoft.NETCore.App are still added during evaluation.