Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# visual studio how to relocate nuget package folder?

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>

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" />

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.

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?

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.

like image 907
sapbucket Avatar asked Dec 03 '16 00:12

sapbucket


People also ask

What is C full form?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C language?

C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.

What is main () in C?

Every C program has a primary function that must be named main . The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program.


1 Answers

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

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

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.

There is more documentation on reinstalling NuGet packages on the NuGet documentation site.

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

like image 107
Matt Ward Avatar answered Sep 23 '22 14:09

Matt Ward