【问题标题】:Is it possible to filter nuget packages by supported platform?是否可以通过支持的平台过滤 nuget 包?
【发布时间】:2016-06-01 11:21:27
【问题描述】:

例如,如果我只想要 .Net Platform Standard 的包。现在我在找一个包,尝试安装它,得到:

error: Package <name> is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). 
Package <name> supports: portable-win81+wpa81 (.NETPortable,Version=v0.0,Profile=Profile32)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.

我必须重新开始。我看到了支持的平台。这意味着,信息就在那里。

编辑:如果我可以在 Visual Studio 中设置过滤器会更好,但我没有看到,我也没有在 nuget.org 中看到它。所以问题是:有没有办法只为特定平台获取包(这意味着按平台搜索过滤)。我感兴趣的是.Net Platform Standard。我希望,您不会在这里看到模糊的东西。

编辑: Here is the search api 来自 nuget.org

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
    <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0" m:MaxDataServiceVersion="2.0">
        <Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="NuGetGallery.OData">
            <EntityType Name="V2FeedPackage" m:HasStream="true">...</EntityType>
        </Schema>
        <Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="NuGetGallery">
            <EntityContainer Name="V2FeedContext" m:IsDefaultEntityContainer="true">
                <EntitySet Name="Packages" EntityType="NuGetGallery.OData.V2FeedPackage"/>
                <FunctionImport Name="Search" ReturnType="Collection(NuGetGallery.OData.V2FeedPackage)" EntitySet="Packages">
                    <Parameter Name="searchTerm" Type="Edm.String" FixedLength="false" Unicode="false"/>
                    <Parameter Name="targetFramework" Type="Edm.String" FixedLength="false" Unicode="false"/>
                    <Parameter Name="includePrerelease" Type="Edm.Boolean" Nullable="false"/>
                </FunctionImport>
                <FunctionImport Name="FindPackagesById" ReturnType="Collection(NuGetGallery.OData.V2FeedPackage)" EntitySet="Packages">
                    <Parameter Name="id" Type="Edm.String" FixedLength="false" Unicode="false"/>
                </FunctionImport>
                <FunctionImport Name="GetUpdates" ReturnType="Collection(NuGetGallery.OData.V2FeedPackage)" EntitySet="Packages">
                    <Parameter Name="packageIds" Type="Edm.String" FixedLength="false" Unicode="false"/>
                    <Parameter Name="versions" Type="Edm.String" FixedLength="false" Unicode="false"/>
                    <Parameter Name="includePrerelease" Type="Edm.Boolean" Nullable="false"/>
                    <Parameter Name="includeAllVersions" Type="Edm.Boolean" Nullable="false"/>
                    <Parameter Name="targetFrameworks" Type="Edm.String" FixedLength="false" Unicode="false"/>
                    <Parameter Name="versionConstraints" Type="Edm.String" FixedLength="false" Unicode="false"/>
                </FunctionImport>
            </EntityContainer>
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

当我使用Search function 时,“searchTerm”参数有效,但“targetFramework”参数无效。

另一个编辑:Fiddler 中的 VisualStudio NuGet HTTP 请求:

GET /api/v2/Search()?$filter=IsAbsoluteLatestVersion&searchTerm='mvv'&targetFramework='netcoreapp1.0'&includePrerelease=true&$skip=0&$top=26 HTTP/1.1

目标框架是从 Visual Studio NuGet 包管理器自动设置的。实际上不起作用的是来自 NuGet 的搜索 api 中的 targetFramework 参数

【问题讨论】:

  • 在本地、nuget.org 或构建期间找到它们?很想得到我的第一个赏金,但问题有点模糊;)
  • @Thomas 没有理由一个答案不能包括所有三个!使其适用于更广泛的受众只会增加您获得一两个闪亮金徽章的机会;)

标签: c# .net-core asp.net-core-1.0


【解决方案1】:

NuGet 可以选择以here 中提到的框架为目标

有一个与您的场景匹配的开放功能请求on github

当我遇到this page 时,我觉得有可能使用 Power shell 控制台脚本来实现您的过滤。请参阅“获取 FrameworkName”部分。

【讨论】:

    猜你喜欢
    • 2020-06-17
    • 2015-01-22
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    相关资源
    最近更新 更多