Pharmacist: [BUG] NugetTask fail when project has dependencies hosted on private repos

Describe the bug

When your csproj reference package that are not hosted on nuget.org, it makes the build fail on PharmacistNuGetTask

Steps To Reproduce

Provide the steps to reproduce the behavior: In your csproj add a PackageReference to a nuget package that is hosted on a private repo

Expected behavior

No build errors, and Pharmacist.Nuget.g.cs generated for all nuget packages (or at least the ones that could be downloaded)

Environment

  • OS: macOS/Windows
  • Device:
  • Version: 1.2.2
  • Working Version:

Additional context Copy of stacktrace : /.nuget/packages/pharmacist.msbuild/1.2.2/buildTransitive/netstandard2.0/Pharmacist.MSBuild.targets(5,5): Error: PharmacistNuGetTask: System.NullReferenceException: Object reference not set to an instance of an object at NuGet.Protocol.DownloadResourceV3.GetDownloadUrl (NuGet.Packaging.Core.PackageIdentity identity, NuGet.Common.ILogger log, System.Threading.CancellationToken token) [0x0007a] in <dc62bc184e5f4ea0bb4b5acbc8632326>:0 at NuGet.Protocol.DownloadResourceV3.GetDownloadResourceResultAsync (NuGet.Packaging.Core.PackageIdentity identity, NuGet.Protocol.Core.Types.PackageDownloadContext downloadContext, System.String globalPackagesFolder, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) [0x000bd] in <dc62bc184e5f4ea0bb4b5acbc8632326>:0 at Pharmacist.Core.NuGet.NuGetPackageHelper+<>c__DisplayClass16_0.<GetPackagesToCopy>b__4 (System.ValueTuple2[T1,T2] item) [0x00094] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.Core.NuGet.NuGetPackageHelper.GetPackagesToCopy (System.Collections.Generic.IReadOnlyCollection1[T] startingPackages, NuGet.Protocol.Core.Types.DownloadResource downloadResource, System.Collections.Generic.IReadOnlyCollection1[T] frameworks, System.Boolean getDependencies, System.Threading.CancellationToken token) [0x001f2] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.Core.NuGet.NuGetPackageHelper.DownloadPackageFilesAndFolder (System.Collections.Generic.IReadOnlyCollection1[T] packageIdentities, System.Collections.Generic.IReadOnlyCollection1[T] frameworks, NuGet.Protocol.Core.Types.DownloadResource downloadResource, System.Boolean getDependencies, System.Collections.Generic.IReadOnlyCollection1[T] packageFolders, System.String packageOutputDirectory, System.Threading.CancellationToken token) [0x00084] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.Core.NuGet.NuGetPackageHelper.DownloadPackageFilesAndFolder (System.Collections.Generic.IReadOnlyCollection1[T] libraryIdentities, System.Collections.Generic.IReadOnlyCollection1[T] frameworks, NuGet.Configuration.PackageSource nugetSource, System.Boolean getDependencies, System.Collections.Generic.IReadOnlyCollection1[T] packageFolders, System.String packageOutputDirectory, System.Threading.CancellationToken token) [0x00288] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.Core.Extractors.NuGetExtractor.Extract (System.Collections.Generic.IReadOnlyCollection1[T] targetFrameworks, System.Collections.Generic.IReadOnlyCollection1[T] packages, System.String packageOutputDirectory) [0x0008a] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.Core.ObservablesForEventGenerator.ExtractEventsFromNuGetPackages (System.IO.TextWriter writer, System.Collections.Generic.IReadOnlyCollection1[T] packages, System.Collections.Generic.IReadOnlyCollection`1[T] frameworks, System.String packageOutputFolder) [0x00090] in <c092543ffe3f4af794d331f791699d8f>:0 at Pharmacist.MsBuild.PharmacistNuGetTask.Execute () [0x0014b] in <dbd6b584cb9d495380a229a5b08a7646>:0 (Tech5.Core)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@glennawatson thanks for all of your hard work on Pharmacist, it’s a great concept and I think the new Source Generator version will be even better! 💖

We are moving to source generators for next revision which doesn’t suffer from nuget source issues. Just have to wait for the visual studio version that supports it next week n

And sarcastic comments absolutely makes things happen faster.

Again asking what the status of this issue is, since it looks like I’m again running into it.

Since my last post here I simply continued using ReactiveUI.Events.*, but have now upgraded Xamarin Forms to version 5.0. With this upgrade, the Expander-control, previously a part of XF, has now been moved into the Xamarin Community Toolkit (see here). Consequently, issues have arisen in using the ReactiveUI.Events.XamForms-package that still contains references to the control that now no longer exists.

I thought I could work around this issue by generating events for Xamarin Forms and Xamarin Essentials myself, in a separate project within my solution. This “events”-project is then referenced by those projects previously using packages from the ReactiveUI.Events.*-namespace. However, when building my solution, I’m now getting the exact same error as above again. It looks like Pharmacist doesn’t just run on the project I set up separately to generate my events for me, but simply runs over all my projects, looking for events…