简体   繁体   English

在 VS Code 中保留 Nuget 包的本地副本

[英]Keep local copy of Nuget Package in VS Code

In Visual Studio Code, i would like to keep a local copy of a referenced Nuget package in the project folder for the case the package will not be available online for some reason in the future.在 Visual Studio Code 中,我想在项目文件夹中保留引用的 Nuget 包的本地副本,以防将来由于某种原因该包将无法在线使用。

nuget restore shall still be able to download it from the internet if the local copy is not yet there.如果本地副本尚未存在, nuget restore仍应能够从 Internet 下载它。

I think thats exactly the behaviour with Visual Studio, but i can't get this running with Visual Studio Code我认为这正是 Visual Studio 的行为,但我无法使用 Visual Studio Code 运行它

I think i found a solution myself.我想我自己找到了解决方案。

Adding a file called nuget.config with the following content to the project folder does exactly what I wanted.将包含以下内容的名为nuget.config的文件添加到项目文件夹中正是我想要的。 The packages are now put into the local packages folder.这些包现在被放入本地packages文件夹中。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
    <add key="globalPackagesFolder" value="packages" />
    <add key="repositoryPath" value="packages" />
</config>
</configuration>

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

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