0

I'm trying to update this NuGet UWP library but since I switched to the UWP SDK 17134 (both as minimum and target version), it seems like all the PackageReference I have get lost during the packaging process.

As a result NuGet just shows "no dependencies", and the packages used by the lib are not automatically restored when using it in another application/library.

This all used to work perfectly fine up until the SDK 16299, and it still does when targeting that SDK. The issue only seems to happen with SDK 17134 or greater.

Also, I'm using NuGet version 4.7.0.5148.

This is how the .csproj file look like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    ...
</PropertyGroup>
<ItemGroup>
    <Compile Include="SomeSampleCodeFile.cs" />
    ...
    <EmbeddedResource Include="Properties\UICompositionAnimations.rd.xml" />
</ItemGroup>
<ItemGroup>
    <PackageReference Include="JetBrains.Annotations">
    <Version>2018.2.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
    <Version>6.1.5</Version>
    </PackageReference>
    <PackageReference Include="Win2D.uwp">
    <Version>1.23.0</Version>
    </PackageReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
    <VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
</Project>

I usually just build the package in Release mode, Any CPU from VS, then call:

nuget pack ProjectName.csproj -Prop Configuration=Release

to build the NuGet package to upload.

NOTE: I noticed that when switching from SDK 16299 to 17134, VS switched from using the project.json file for the references, to just including the various PackageReference items directly into the .csproj file, and I guess NuGet didn't like that. Is there something I have to do to specifically enable this for a UWP library? I mean, I do have other NuGet libraries targeting .NET Standard that work just fine with PackageReference items

I'm not sure what I'm doing wrong here, or if I'm supposed to add something to make those references come back when targeting this new SDK.

Thanks for your help!

Sergio0694
  • 4,447
  • 3
  • 31
  • 58
  • I would suggest closing VS, trying to delete all leftover project.json files in the project and deleting the `bin` and `obj` folders in your solution. It sometimes happens that NuGet gets confused because there are "old package reference" type leftovers in these folders and doesn't know what to do. – Martin Zikmund Sep 04 '18 at 14:32
  • @MartinZikmund Already tried that, unfortunately I got the same results, NuGet keeps showing no dependencies for the package. At this point I wonder if `PackageReference` items are supported for UWP packages (not applications) at all, at least for now. – Sergio0694 Sep 04 '18 at 14:42
  • Maybe as expirement - try it with a basic empty app and library – Martin Zikmund Sep 04 '18 at 14:57
  • @MartinZikmund Already tried that as well, as soon as I target SDK 17134 (and therefore switch from project.json to the `PackageReference` format), NuGet loses track of all dependencies and shows none – Sergio0694 Sep 04 '18 at 16:13
  • 1
    Very interesting. I will try to replicate on my PC when I get home – Martin Zikmund Sep 04 '18 at 19:28

0 Answers0