3

I've read this question about what the obj and bin folders are.

My APP/obj/CONFIGURATION folders contain hundreds of files. This includes a copy of every form (as a .resources file), icon, image (.bmp, .jpg, etc), multi-language translation file, and so on. The build takes up to three (painful!) minutes to complete.

  • Do these intermediate files have to hit disk in this way?
  • Can Visual Studio be configured to not hit disk with all these copies, but to link everything in memory?

This is a C#.NET application, if relevant.

Community
  • 1
  • 1
AlainD
  • 5,413
  • 6
  • 45
  • 99
  • Get an SSD. It'll make a huge difference. – Matthew Watson Dec 03 '15 at 10:29
  • 1
    @MatthewWatson: Nice idea, but not immediately practical! :o) – AlainD Dec 03 '15 at 10:30
  • Unfortunately you can't configure VS to do the build in memory. – Matthew Watson Dec 03 '15 at 10:32
  • 1
    I did small research for that and switched to building project to ramdisk and putting output of all projects to 1 folder, in my case it worked pretty well I'd say. You can also try linking files in output folders for your projects using MKLINK and "copy if newer" option, but that might be a real pain – Red Dec 03 '15 at 10:34
  • 1
    Can RAM disk be another option for you if SSD is not? – Vijay Gill Dec 03 '15 at 10:34
  • @MatthewWatson WRONG – Matías Fidemraizer Dec 03 '15 at 10:39
  • @MatíasFidemraizer: Your comment is not constructive. Where exactly is Matthew wrong? If it is because you can create a RAM disk as per your answer, then perhaps mention that. I'm certainly here to learn... – AlainD Dec 03 '15 at 10:48
  • @AlainD Well, when you emit a strong statement it should be because you're absolutely sure about you're talking about... – Matías Fidemraizer Dec 03 '15 at 10:51
  • @MatíasFidemraizer It is the case that you cannot configure Visual Studio to do a build in memory. Of course you can use a RAM disk, but that's nothing to do with configuring Visual Studio. I am indeed absolutely certain that there is no configuration option in Visual Studio specifically for making it store intermediary compilation files in memory. – Matthew Watson Dec 03 '15 at 11:50
  • @MatthewWatson It would be wonderful! – Matías Fidemraizer Dec 03 '15 at 12:03

1 Answers1

4

In my case I'm using ImDisk to create a RAM disk, and then I instruct Visual Studio to put some temp files stored in the whole RAM disk (M: is the RAM disk's drive letter) using a simple BAT/CMD file:

set TEMP=M:\vstemp
set TMP=M:\vstemp
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"

In the other hand, I've customized my build to point the $(OutputPath) to a directory in the RAM disk.

Also, I've found this other Q&A with info to change obj directory somewhere else: VisualStudio: How to save the obj folder somewhere else.

Anyway, a solid-state disk boosts overall Visual Studio performance, and using both SSD+RAMDisk approach will avoid a lot of write operations to the SSD, which will increase its lifetime.

Community
  • 1
  • 1
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • Thanks for the tip about ImDisk. The tool looks awesome just busy giving it a try now. Since it is not possible to ask Visual Studio to not output temporary linker files, the RAM disk seems like the way to go. – AlainD Dec 03 '15 at 10:46
  • @AlainD Well, don't dream you'll be able to move everything to the RAMDisk. MSBuild still will hit the HDD/SSD, BTW, if you customize your build enough, you'll be able to more more than the 50% of created files to the RAM disk – Matías Fidemraizer Dec 03 '15 at 10:50
  • Note that this will cause temp files produced by ALL programs to be written to the RAM disk. This will probably be fine unless some application tries to write a file bigger than your RAM disk, at which point you will get "out of disk space" errors. – Matthew Watson Dec 03 '15 at 11:55
  • @MatthewWatson AFAIK this isn't true, you're setting these environment variables for the process where they're being set. It does not affect other apps. – Matías Fidemraizer Dec 03 '15 at 11:59
  • @MatthewWatson Just try it yourself. `SET TEMP` in a CMD and open another one, and try `ECHO %TEMP%`. – Matías Fidemraizer Dec 03 '15 at 12:00
  • @MatíasFidemraizer Ah yes, you're correct - I missed the crucial line in the batch file. :) – Matthew Watson Dec 03 '15 at 12:00
  • @MatíasFidemraizer: Quick question about the BAT/CMD you mention. Are you referring to something like a .bat file used to launch Visual Studio (eg. instead of opening VS directly using a Windows shortcut)? – AlainD Dec 03 '15 at 15:14
  • @AlainD Yeah, that's it – Matías Fidemraizer Dec 03 '15 at 15:18