c# - Nuget 问题:接口一直引用旧版本
问题描述
我正在运行一个解决方案,其中使用了多个 nuget 包。在我的“域”nuget 中,我指定了以下接口:
(在文件:ecnuget.domain中,nuget 版本设置为1.0.10):
public interface IItemPriceStore
{
Task<bool> AddPriceUpdateAsync(PriceUpdate priceUpdate);
Task<bool> InitializeAsync();
Task<IEnumerable<PriceUpdate>> GetByItemName(string itemName);
}
最后两种方法在 nuget 包的 1.0.7 版本中不存在,但它们是在相同的 1.0.10 版本中添加的。
现在,在一个实现中,我更新了对版本 1.0.10 的引用,并且预计会看到构建错误,因为 ItemPriceStore 类还没有实现这两个新方法,但是它仍然可以构建!当我 F12 界面时,我看到:
#region Assembly ecnugget.domain, Version=1.0.7.0, Culture=neutral, PublicKeyToken=null
// C:\Users\pedro\.nuget\packages\ecnugget.domain\1.0.10\lib\netcoreapp3.1\ecnugget.domain.dll
#endregion
using digitaldias.ec.domain.Entities;
using System.Threading.Tasks;
namespace digitaldias.ec.domain.Contracts.Writers
{
public interface IItemPriceStore
{
Task<bool> AddPriceUpdateAsync(PriceUpdate priceUpdate);
}
}
而且我一生都无法弄清楚为什么或什么引用了旧的 1.0.7 版本。我尝试过的事情:
- 删除对包的引用并重新安装/重建
- 清除包缓存
- 删除所有包
- 删除 nuget.config
- 删除存储元数据的临时文件夹
- 删除所有 .suo 文件
- 完全删除 .vs 文件夹
我已经通过重新启动 Visual Studio 完成了所有这些操作,甚至关闭了所有 Visual Studio 实例。
我的 .csproj 只引用了这个包的 1.0.10 版本,然而,由于某种神秘的原因,当我构建时,它一直在创建对 1.07 版本的元数据引用。我无法为我的生活找出引用 1.0.7 的位置。我在任何源文件中都找不到它!
这是我当前实现接口的 .csproj 中的引用:
<ItemGroup>
<PackageReference Include="ecnugget.domain" Version="1.0.10" />
<PackageReference Include="PubSub" Version="4.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
希望有人有同样的经验,可以帮助我。
解决方案
只是一个提示,请参阅此线程。
尝试启用自动绑定重定向。将此添加到您的 .csproj 文件中
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
推荐阅读
- android - 在应用程序被杀死时处理 FCM 通知
- reactjs - 'this' 隐含类型为 'any' 因为它没有类型 annotation.ts(2683) : 'this' 的外部值被此容器遮蔽
- java - 多个活动的推送通知
- java - 需要使用retrofit2从api返回的响应中获取字符串
- c - 如何使用结构和数组存储双精度组
- c# - 为什么 myCounters[2] 重置时 mycounter[0] 的值会发生变化?(理论)
- python - 添加 ForeignKey 的多个实例
- python - Select column in pivot table output
- python - Python pip 安装 mysqlclient
- azure-active-directory - 请求 offline_access 时 AAD 未提供 refresh_token