C#Visual Studio如何重新放置nuget包文件夹? [英] C# visual studio how to relocate nuget package folder?

查看:370
本文介绍了C#Visual Studio如何重新放置nuget包文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我雇了一个承包商为我做一些编码.他使用以下存储库路径在解决方案文件夹中设置了nuget.config:

I hired a contractor to do some coding for me. He setup nuget.config in the solution folder with the following repository path:

<configuration>
  <solution>
    <add key="disableSourceControlIntegration"
      value="true" />
  </solution>
  <config>
    <add key="repositoryPath"
      value="../lib" />
  </config>
</configuration>

我对他的决定不太满意:这会将nuget包文件夹放在解决方案文件夹之外.我只需设置即可轻松更改存储库路径:

And I'm not too happy about his decision: this will place the nuget package folder outside the solution folder. I can easily change the repository path, simply by setting:

value="../<mySolutionFolder>/lib" />

但是,当我这样做时,会发生一个奇怪的事情:我在解决方案中使用的每个引用现在都已损坏.我在.csproj文件或其他* .config文件中所做的任何更改都不会使我的项目找到它们的引用.

However when I do this a curious thing happens: every single reference that I use in my solution is now broken. And nothing that I change in the .csproj files or other *.config files will allow my projects to find their references.

唯一的解决方法是从头开始重新创建解决方案中的每个项目,然后添加->现有项目等,然后引用->管理nuget软件包,然后重新安装每个引用.

The only workaround is to re-create each project in my solution by starting from scratch, and add->existing items, etc. and reference->manage nuget packages, and install every reference again.

我的解决方案中有很多项目,而每个项目都要执行,这是很耗时的.

I have many projects in my solution and performing this for every one is understandably time consuming.

我想知道是否有一种简单的方法?

I would like to know if there is an easy way?

似乎应该有一种让Nuget和VS很好玩的方法,这样我就可以轻松将存储库文件夹移动到其他路径位置.

It seems like there should be a way for Nuget and VS to play nicely so that I can easily move the repository folder to a different path location.

推荐答案

固定参考路径的一种方法是使用程序包管理器控制台.

One way to fix the reference paths is to use the Package Manager Console.

从程序包管理器控制台中,您可以运行以下命令来重新安装NuGet程序包,该程序包将修复引用的提示路径.

From the Package Manager Console you can run the following command to reinstall the NuGet packages which will fix the hint paths for the references.

Update-Package -reinstall

这将重新安装解决方案中的所有NuGet软件包.我假设您已经将代码包含在源代码控制下,因此如果您需要在重新安装后恢复它们,则可以查看对项目进行了哪些更改.

This will reinstall all NuGet packages in the solution. I am assuming you have the code under source control so you can see what changes are made to the projects if you need to revert them after this reinstall.

关于在NuGet文档上重新安装NuGet软件包,有更多文档.网站.

解决此问题的另一种方法是在.csproj文件中查找并替换以修复提示路径.

Another way to fix this is to do a find and replace in the .csproj files to fix the hint path.

这篇关于C#Visual Studio如何重新放置nuget包文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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