Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Is there a way to identify a nuget reference? #27

Closed
tecnocrata opened this issue Jun 26, 2020 · 3 comments
Closed

Is there a way to identify a nuget reference? #27

tecnocrata opened this issue Jun 26, 2020 · 3 comments
Labels

Comments

@tecnocrata
Copy link

Hello there,
I'm using this fantastic library and have a question, I'm parsing a csproj file. with something like this:

foreach (IXProject xp in sln.Result.Env.Projects)
                    {
...

and I want to identify which references are nuget or not, Is there a way to do that?
I'm using this

xp.GetItems("Reference")

but that instruction returns all references, including nuget ones but not sure how to identify in them on that list

Any help would be appreciated

@3F
Copy link
Owner

3F commented Jun 26, 2020

Depends on what type of NuGet references you need.

As I voiced here 3F/DllExport#152 (comment)
At least:

  • PackageReference
  • Legacy PackageReference
  • packages.config

I know, this part is not so good covered for most convenient use today. Any PR welcomed! But I think it will be reviewed together with planned 3.0 (within IeXod integration) or a bit later.

Today, however, you can try GetItems("PackageReference") including legacy types.

For packages.config you can try to adapt my implementation here https://github.com/3F/DllExport/blob/master/Wizard/LegacyPackagesFile.cs But I think we should consider a common implementation like LegacyPackagesFile as part of MvsSln and/or IeXod.

Let me know if you still have some problems or questions.

@tecnocrata
Copy link
Author

thank you 3F

@3F
Copy link
Owner

3F commented Jul 5, 2020

@tecnocrata
You're welcome. I'm glad to hear that was helpful!

Some related improvements will be considered later.
Just follow the news.

@3F 3F closed this as completed Jul 5, 2020
3F added a commit that referenced this issue Aug 23, 2021
* FIXED: Fixed CalculateHashCode() Extension.
         Internally affects many objects due to broken GetHashCode().

* FIXED: Fixed SlnItems.ProjectDependenciesXml when empty input:
         Report #25 (comment)

* NEW: packages.config support PR #30. Related issues #27, #28.
       To activate it, use the following flags:
        * PackagesConfig, PackagesConfigSolution, PackagesConfigLegacy.

        For example,
        ```
        using Sln l = new("Input.sln", SlnItems.AllNoLoad | SlnItems.PackagesConfig);

        IPackageInfo found = l.Result.PackagesConfigs
                                        .SelectMany(s => s.Packages)
                                        .FirstOrDefault(p => p.Id.StartsWith("Microsoft."));
        // found.MetaTFM ...

        Version v = l.Result.PackagesConfigs.First().GetPackage("LX4Cnh")?.VersionParsed;
        ```
          Including GetNuTool compatible packages, format:
          https://github.com/3F/GetNuTool#format-of-packages-list

* NEW: Added HasValue and HasNothing properties in PropertyItem.

* NEW: Added SlnItems.AllMinimal and SlnItems.AllNoLoad in addition to SlnItems.All.

* NEW: Added IXProject.GetPackageReferences().

* CHANGED: ConfigItem.Format() marked as obsolete.
           Use `ToString()` and `IConfPlatform.Formatted` instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants