简体   繁体   English

在单个.sln中管理本地nuget行为

[英]Managing local nuget depedencies in single .sln

I created a solution containing 2 DLLs that are published as nugets. 我创建了一个包含2个以nuget形式发布的DLL的解决方案。 I took Hangfire as an exemple. 我以Hangfire为例。

So, if I have a DLL named hangfire and a second one hangfire.sql, this mean hangfire.sql depends on hangfire. 因此,如果我有一个名为hangfire的DLL和第二个hangfire.sql,则意味着hangfire.sql取决于hangfire。 hangfire.sql is refering hangfire as a nuget and not a project dll. hangfire.sql将hangfire称为nuget,而不是项目dll。 Then, even if I specify the dependency in the .sln, I get an error when I build the solution saying the first nuget couldn't get restored. 然后,即使我在.sln中指定了依赖关系,在构建解决方案时也会收到一条错误消息,指出无法还原第一个nuget。

Is it doable? 可以吗 The alternative I see is hangfire.sql to use the version already published of hangfire and not the version present in the .sln 我看到的替代方法是hangfire.sql,它使用的是hangfire已发布的版本,而不是.sln中存在的版本。

I'm on Visual Studio 2019 我正在使用Visual Studio 2019

Thanks 谢谢

We solved this by adding dotnet restore in the .csproj as follow: 我们通过在.csproj中添加dotnet restore来解决此问题,如下所示:

<Target Name="NuGet restore" BeforeTargets="BeforeBuild">
    <Exec Command="dotnet restore" />
</Target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM