Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pack command generates incorrect dependencies #484

Closed
clairernovotny opened this issue Dec 13, 2016 · 4 comments
Closed

Pack command generates incorrect dependencies #484

clairernovotny opened this issue Dec 13, 2016 · 4 comments

Comments

@clairernovotny
Copy link
Member

I have a project which cross compiles to many target frameworks, including desktop .NET 4.5.

I have the NETStandard.Library excluded from net45 as many users complain when adding that dependency. When I then run msbuild /t:pack or dotnet pack (same thing), the dependencies it generates includes netstandard1.0 (which is a valid target platform), but it does not generate an empty group for net45. It's not properly calculating the dependencies that only affect net45.

The result is that the net45 package will resolve and get the netstandard1.0 set of dependencies because there's no explicit net45 dependency group and that's the problem.

Here's what it generates:
img

And here's the csproj that created it.

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!--<Import Condition=" '$(TargetFramework)' == 'uap10.0'"  Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />-->
  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8</TargetFrameworks>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'win8'">
    <TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'wpa81'">
    <TargetFrameworkIdentifier>WindowsPhoneApp</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'portable-win81+wpa81'">
    <TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
    <NugetTargetMoniker>UAP,Version=v10.0</NugetTargetMoniker>
    <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
    <TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
    <TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'portable-win81+wpa81' ">
    <Reference Include="System" />
    <Reference Include="System.Runtime" />
    <Reference Include="System.Runtime.Extensions" />
    <Reference Include="System.Resources.ResourceManager" />
    <Reference Include="System.Core" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'wp8'">
    <TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="NETStandard.Library" Version="1.6.1" Condition="'$(TargetFramework)' != 'net45'"/>
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'win8' or '$(TargetFramework)' == 'wpa81'  or '$(TargetFramework)' == 'wp8' ">
    <Reference Include="System" />
    <Reference Include="System.Runtime" />
    <Reference Include="System.Runtime.Extensions" />
    <Reference Include="System.Resources.ResourceManager" />
    <Reference Include="System.Core" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="5.2.2" />
    <PackageReference Include="Microsoft.TargetingPack.Private.WinRT" Version="1.0.3">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>
@clairernovotny
Copy link
Member Author

/cc @yishaigalatzer @emgarten @rrelyea

@emgarten
Copy link
Member

Looks like a bug. Pack should create a group for each TFM in the project for each asset type (ex: lib, build, dependencies) to avoid falling back to the wrong group like you are seeing here.

@clairernovotny
Copy link
Member Author

clairernovotny commented Dec 13, 2016

It happened when there should have been an empty dependency group. When I added a "global" System.Reactive dependency for all targets, it created one for net45 that only included that one.

@srivatsn
Copy link
Contributor

Moved to NuGet/Home#4137

mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…213.1 (dotnet#484)

This change updates the following dependencies
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19113.1
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants