dasMulli / nuget-include-p2p-example

Example of a NuGet package including its ProjectReference projects
14 stars 2 forks source link

Hack 2 from StackOverflow #1

Open UncleFirefox opened 6 years ago

UncleFirefox commented 6 years ago

Hi, I'm trying hack 2 from your answer on stack overflow using:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
    <PackageId>Aeron.Client</PackageId>
    <Version>1.4.1.0</Version>
    <Authors>Adaptive Financial Consulting Ltd.</Authors>
    <Company>Adaptive Financial Consulting Ltd.</Company>
    <Product>Aeron Client</Product>
    <Copyright>Copyright 2017</Copyright>
    <PackageLicenseUrl>https://github.com/AdaptiveConsulting/Aeron/blob/master/LICENSE</PackageLicenseUrl>
    <PackageProjectUrl>https://github.com/AdaptiveConsulting/Aeron/</PackageProjectUrl>
    <PackageIconUrl>https://raw.githubusercontent.com/AdaptiveConsulting/Aeron.NET/master/images/adaptive.png</PackageIconUrl>
    <Description>Efficient reliable UDP unicast, UDP multicast, and IPC transport protocol.</Description>
    <PackageTags>aeron client messaging networking transport udp ipc</PackageTags>
    <PackageReleaseNotes>https://github.com/real-logic/aeron/wiki/Change-Log</PackageReleaseNotes>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Adaptive.Agrona\Adaptive.Agrona.csproj" PrivateAssets="All" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <_PackageFiles Include="$(OutputPath)\Adaptive.Agrona.dll">
      <BuildAction>None</BuildAction>
      <PackagePath>lib\net452\</PackagePath>
    </_PackageFiles>
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
    <_PackageFiles Include="$(OutputPath)\Adaptive.Agrona.dll">
      <BuildAction>None</BuildAction>
      <PackagePath>lib\netstandard2.0\</PackagePath>
    </_PackageFiles>
  </ItemGroup>

</Project>

Project is very simple but it doesn't copy Adaptive.Agrona.dll into the pkg, any ideas on why it's failing?

dasMulli commented 6 years ago

I think I can revise it to something much more simple for the 2.0.0 tooling:

<Project>
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;netstandard1.6</TargetFrameworks>
    <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2PAssets</TargetsForTfmSpecificBuildOutput>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\testprivatelib\testprivatelib.csproj" PrivateAssets="All" />
  </ItemGroup>

  <Target Name="IncludeP2PAssets">
    <ItemGroup>
      <BuildOutputInPackage Include="$(OutputPath)\testprivatelib.dll" />
    </ItemGroup>
  </Target>
</Project>
dasMulli commented 6 years ago

let me know if this works for you

sonudavidson commented 4 years ago

Hi, I updated the target framework to frameworks like this way

netstandard1.4;net471

Added the same line in all the 3 projects,

While building the solution, I get the following error,

error NU5019: File not found: 'bin\Debug\LibA.dll'

Looks like a similar change, Couldn't figure out the reason. Looking for some help.

Thanks!

dasMulli commented 4 years ago

@sonudavidson did you start with one of the code snippets in this thread? if so, which?

sonudavidson commented 4 years ago

@dasMulli Thanks for the reply. It was my mistake. I was able to solve it. Although I have another issue, Sometimes, the values from .csproj file are not referenced properly in NuSpec. Do you also see this issue?

dasMulli commented 4 years ago

There are two ways of packing a nuspec. packing the nuspec and referencing the nuspec from a csproj for dotnet pack. First one doesn't really work with .net core projects, second one also requires you to construct the set of variables for the nuspec inside the csproj. I usually recommend not using either of them and maxing out what can be done with csproj alone. There are only a few things that cannot be done in csproj (e.g. reference groups for packages.config base projects)

sonudavidson commented 4 years ago

Yeah, I agree. I took off the part where the values must be referenced from .csproj. Nuspec now works.