使用本地项目引用覆盖 nuget 包引用 [英] Override a nuget package reference with a local project reference

查看:51
本文介绍了使用本地项目引用覆盖 nuget 包引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迭代 nuget 包,而不是不断地将包推送到 nuget 提要.

I'd like iterate on a nuget package without continuously pushing the package to a nuget feed.

我想知道是否可以通过 csproj 文件中的目标或道具文件有条件地添加项目引用而不是 nuget 包引用,这将允许我在本地调试我的 nuget 包.

I'm wondering if it's possible to conditionally add a project reference instead of a nuget package reference via a target or props file in csproj files that would allow me to locally debug my nuget package.

在我的 csproj 中,我会:

In my csproj I would have:

<Reference Include="A">
    if(Exists(localOverrides.props) {
        <HintPath>localOverrides.A.HintPath</HintPath>
    } else {
        <HintPath>..\packages\A.dll</HintPath>
    }
</Reference>

和 localOverrides.props 将是我的 .gitignore 中列出的文件,开发人员可以添加行来喜欢:

and localOverrides.props would be a file listed in my .gitignore that developers could add lines to like:

A -> C:\Repos\A\bin\A.dll

我走错路了吗?当然,必须有一种更可持续的方法来快速迭代和调试 nuget 包,然后在每次更改时创建预发布包

推荐答案

我一直调试 Nuget 包的方式是,一旦您通过 Nuget 将该包添加到您的解决方案中,您就可以更改 Nuget DLL 并复制它们到使用 Nuget 包的项目的包文件夹中的正确文件夹中.

The way I have always debugged Nuget package is once you have that package added to your solution through Nuget, you then make changes to the Nuget DLLs and just copy them into the correct folder in the packages folder for the project consuming the Nuget package.

您所要做的就是在调试模式下编译 Nuget 项目解决方案的解决方案,然后将它们复制/粘贴到使用项目的包文件夹中.您可以通过编写批处理脚本并将其作为构建后事件添加到刚刚将 DLL 复制到正确文件夹中的 Nuget 项目来简化此操作.

All you have to do is compile the solution that Nuget project solution in debug mode and just copy/paste them into the consuming project's packages folder. You could make this even simpler by writing a batch script and adding it as a post build event to the Nuget project that just copied the DLLs into the correct folder for you.

这篇关于使用本地项目引用覆盖 nuget 包引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆