noodles
noodles

Reputation: 35

I moved the directory of visual studio to a different drive, now I cannot compile

My C: drive is strictly for windows (a 64GB SSD), and recently learned that it was nearly full. I changed my program files directory to D:/ProgramFiles and all the contents of my old program files to the new directories. Now, trying to compile a program in Visual Studio 2017 Community will give me an error:

The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found.

How can I tell visual studio where I moved my files to?

EDIT: I have already installed Visual Studio itself (devenv.exe) under "Visual Studio 2K17", but I've moved the assemblies (NOT visual studio) to the D drive. If i choose to reinstall, it will still put files on my C drive.

Upvotes: 1

Views: 1059

Answers (4)

schlebe
schlebe

Reputation: 3715

This can be solved in defining a Junction folder using MKLINK Dos command.

I used this technic to move c:\Program Files\dotnet folder to d: drive in same folder name.

Here is my BAT script

set folder=\Program Files\dotnet
xcopy /E/H/O "C:%folder%" "D:%folder%"
rename "C:%folder%" "dotnet.$"
mklink /J "C:%folder%" "D:%folder%"
rmdir /S/Q "C:%folder%.$"

But to be safe, I executed all these commands manually to be sure that all is working well.

I executed XCOPY manually to be sure that all files have been copied.

I executed RENAME command manually but it return an error because some files are IN USE.

So I used File LockSmith from Microsoft Power Toys to find locking processes and try to deactive them. Deactivating processes from File LockSmith doesn't work because somes services are automatically restarted. Finally, I use service name returned by File LockSmith to deactivate services manually. When all locking services has been deactivated, I renamed dotnet folder manually as administrator.

I executed MKLINK manually without problem.

I tested my work during one week without problem.

Then I decide to start RMDIR command to free fast 1GB of space.

Upvotes: 0

noodles
noodles

Reputation: 35

After doing a repair of visual studio (took roughly 15-20 minutes on a 3MBPS connection), everything was working fine again and everything installed to the new program files directory.

Upvotes: 0

user3390116
user3390116

Reputation: 48

You can make a Junction folder, I had the same space issue, and I moved all the files to another drive. in case you remember which folders you moved you can still get it working.

Let's say I moved "C:\Program Files (x86)\Microsoft ASP.NET" to "D:\Program Files (x86)\Microsoft ASP.NET"

all I do is in the command prompt(you might need to execute CMD with admin priviledges):

mklink /j "C:\Program Files (x86)\Microsoft ASP.NET" "D:\Program Files (x86)\Microsoft ASP.NET"

so mklink /j Dest_Folder SourceFolder

Dest_Folder: where you want your directory junction to appear

SourceFolder: where you moved your folder.

Upvotes: 1

Rahul
Rahul

Reputation: 77876

How can I tell visual studio where I moved my files to?

By uninstalling Visual Studio and re-install it back and while doing so choose the installation path to D:\ drive. simply moving the installation directory to different root drive won't make it since there are registry settings which will be still pointing to C:\ drive installation folder

Upvotes: 2

Related Questions