0

I am new to the C# and nuget world.

I have the issue with https://www.nuget.org/packages/Cumulocity.SDK.Client . Cumulocity.SDK.Client internally has a ProjectReference to Cometd.NetStandard.csproj . And I want to pack and publish the Cumulocity.SDK.Client nuget in such a way that it contains the .dll for Cometd.NetStandard and doesn't search Cometd.NetStandard as nuget dependency after publishing it to nuget repository. Below is the link and screenshots to understand the issue -

The undesired current behaviour - https://www.nuget.org/packages/Cumulocity.SDK.Client/1006.6.1 . The dependencies [screenshot][1] for this shows cometd.NetStandard as a dependency. So when someone tries to download this version of Cumulocity.SDK.Client then they are not able to do it.

The desired old behaviour - https://www.nuget.org/packages/Cumulocity.SDK.Client/0.1.1 . The dependencies [screenshot][2] for this version of nuget shows no dependencies and downloads with no issues and the nuget works fine when there is any usage of cometd.NetStandard within the code then also it works with no issues.

The repository where you find the projects is https://bitbucket.org/m2m/cumulocity-sdk-cs/src/master/ and these are the 2 projects i have have this issue with https://bitbucket.org/m2m/cumulocity-sdk-cs/src/master/REST-SDK/src/ . You can download the projects from these repositories and suggest me how i should pack and publish to get the desired behaviour.

You will be able to help me only after you download this code and understand the issue. I have tried using below command with some variations to pack the nuget , I am expecting exact dotnet pack command and(or) change in .csproj file to get the desired behaviour of nuget.

dotnet pack Cumulocity.SDK.Client.csproj --include-symbols --configuration Release --force --include-source

Thanks in Advance. [1]: https://i.stack.imgur.com/AcAC8.png [2]: https://i.stack.imgur.com/0DZHP.png

Kumar Pallav
  • 31
  • 1
  • 4
  • Look at https://www.nuget.org/packages/Teronis.MSBuild.Packaging.ProjectBuildInPackage/ – Backs Jul 22 '20 at 06:05

1 Answers1

0

Add package Teronis.MSBuild.Packaging.ProjectBuildInPackage and add attribute PrivateAssets="all":

<ProjectReference Include="..\Client.Models\Client.Models.csproj" PrivateAssets="all" />

So, Client.Models.dll will be included in result package

Backs
  • 24,430
  • 5
  • 58
  • 85
  • Is there any possible way to achieve this without adding additional packages and just changing the way i pack the nuget?.. My case seems to be quite typical..you will get to know the complexity when you download the code from repo and try locally. – Kumar Pallav Jul 22 '20 at 06:17
  • @KumarPallav you can take source code and copy-paste it https://github.com/teroneko/Teronis.DotNet – Backs Jul 22 '20 at 06:20
  • @KumarPallav short answer - no – Backs Jul 22 '20 at 06:21
  • I think what i want can be achived without any additional package . This is the link of the nuget for previous version which was published 1 year ago - https://www.nuget.org/packages/Cumulocity.SDK.Client/0.1.1 . It doesn't show anything as it's dependency and the nuget downloads and works fine. I just want to know how i could achieve this behaviour. This was done by some other developer 1 year back and he is no more in the organisation , That is why i have asked this question to the community. – Kumar Pallav Jul 24 '20 at 05:13
  • @Backs thanks for promoting my project. I want to state that my project is licensed under the MIT license. I encourage everyone to take a look at the license of everyone's code before you copy and paste someone's source code. \@KumarPallav, he is right. By using [Teronis.MSBuild.Packaging.ProjectBuildInPackage](https://www.nuget.org/packages/Teronis.MSBuild.Packaging.ProjectBuildInPackage/) you solve one problem, but not THIS problem: [Generating Nuget package on build does not include all dependencies](https://stackoverflow.com/a/66790639/2788957). You need to add System.ServiceModel.Web. – Teneko Mar 25 '21 at 17:12