To do this, add a NuGet.Config file that adds the location of the directory as a feed, so you don't have to add the source parameter to each NuGet-related command (especially dotnet restore):<?xml version="1.0" encoding="utf-8"?><configuration> <packageSources> <add key="local-packages" value="../foo/bin/Debug" /> </packageSources></configuration>或者,在.NET Core 2.0工具/NuGet 4.3.0中,您也可以将源直接添加到应该消耗NuGet提要的.csproj文件中:Alternatively in .NET Core 2.0 tools / NuGet 4.3.0, you could also add the source directly to the .csproj file that is supposed to consume the NuGet feed:<PropertyGroup> <RestoreSources>$(RestoreSources);../foo/bin/Debug;https://api.nuget.org/v3/index.json</RestoreSources></PropertyGroup>这将使所有命令都能够使用该软件包:This will make all commands be able to use the package: dotnet add package foo(可选添加-v 1.0.0) dotnet restore dotnet rundotnet add package foo (optionally add -v 1.0.0)dotnet restoredotnet run请注意,在开发过程中,如果更改了NuGet软件包,但在生成.nupkg文件的项目和使用该文件的项目中都没有增加其版本,则需要清除本地软件包缓存再次恢复之前:Note that during development, if you change the NuGet package, but don't increment its version in both the project that produces the .nupkg file and in the project that consumes it, you'll need to clear your local packages cache before restoring again:dotnet nuget locals all --cleardotnet restore我在 https://github.com/dasMulli/LocalNupkgExample 中创建了一个小示例项目I have created a small example project at https://github.com/dasMulli/LocalNupkgExample 这篇关于在"dotnet"中添加带有本地软件包文件的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 23:51