nuget.config如何指定nuget软件包依赖项版本

发布于 2025-01-29 09:28:20 字数 1279 浏览 1 评论 0原文

我正在尝试制作一个Visual Studio 2019项目,该项目将自动下载Nuget软件包的特定版本,如果新用户打开该项目,它将自动恢复/下载该版本的软件包。

我正在尝试使用nuget.config文件在我的VS2019仓库的基础上进行填写,我的nuget.config包含一个源(文物),

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <clear />
        <add key="repositoryPath" value="packages" />
    </config>
    <packageSources>
        <!-- When <clear /> is present, previously defined sources are ignored -->
        <!-- Remove this tag or un-comment the nuget.org source below to restore packages from nuget.org -->
        <!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
        <clear />
        <add key="Artifactory" value="https://my-artifactory-url/artifactory/api/nuget/ult-testware-nuget" />
    </packageSources>

    <packageRestore>
        <add key="enabled" value="True" />
        <add key="automatic" value="True" />
    </packageRestore>

    <activePackageSource>
        <add key="All" value="(Aggregate source)" />
    </activePackageSource>
</configuration>

但是哪些语法是什么是指定需要下载版本1.0的部分。包含“ martintestpkgxyz”的4个?我可以将其包含在我的nuget.config文件中,以便打开或构建时的软件包和版本会下载吗?

I am trying to make a Visual Studio 2019 project which will automatically download a specific version of a NuGet package, and if a new user opens that project, it will automatically restore/download that version of the package.

I'm trying to acomplish this using a nuget.config file at the base of my VS2019 repo, my nuget.config includes one source (Artifactory),

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <clear />
        <add key="repositoryPath" value="packages" />
    </config>
    <packageSources>
        <!-- When <clear /> is present, previously defined sources are ignored -->
        <!-- Remove this tag or un-comment the nuget.org source below to restore packages from nuget.org -->
        <!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
        <clear />
        <add key="Artifactory" value="https://my-artifactory-url/artifactory/api/nuget/ult-testware-nuget" />
    </packageSources>

    <packageRestore>
        <add key="enabled" value="True" />
        <add key="automatic" value="True" />
    </packageRestore>

    <activePackageSource>
        <add key="All" value="(Aggregate source)" />
    </activePackageSource>
</configuration>

But what is the syntax to include a section that specifies the need to download version 1.0.0 of the package "MartinTestPkgXYZ" ? Can I include that in my nuget.config file so the package and version get downloaded when you open or build?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文