1

I've got a C# project and I need the output path to be a specific directory, say C:\Program Files\foo. Everytime I close the properties information or build it gets set back to ......\Program File\Foo and i'm not able to debug properly because of it.

It worked fine for weeks and now all of a sudden it won't let me set the output directory. Anyone ever encounter this before?

Thanks,

Boumbles
  • 2,473
  • 3
  • 24
  • 42

2 Answers2

4

It's not usually a good practise to use absolute paths, as this locks down your project to a specific location (makes it non-relocatable on your and other people's hard drives), which can become a real problem in the future even for a single developer (e.g. when your hard drive gets full and you have to move the project to D:)

I'd suggest leaving the output path at its default setting (bin\Debug etc) and using a post-build event to copy the resulting .exe to the final deployment location - this is more flexible and will allow debugging of the local copy. If you absolutely have to debug the exe in-situ within Program Files, then you can easily change the Project Properties (Debug section) to run the specific instance of the .exe in Program Files, rather than the Output .exe, so apart from the tiny extra cost of an extra copy in the build, it should allow you to do everything you need to do without fighting VS to get it using an unusual path.

Jason Williams
  • 56,972
  • 11
  • 108
  • 137
  • Under most circumstances I'd agree but I'm working with a very large (and somewhat complex) program and I'm adding just a small part to it. However, I need to have my VS put the dll into a specific directory so the main program knows to look for it there. – Boumbles Mar 21 '11 at 22:46
  • @Boumbles - A post-build command to copy the dll to that specific directory should work fine - it'll achieve almost the same effect as redirecting OutputPath does. – Jason Williams Mar 22 '11 at 23:49
0

How do you set output path? Via project settings tab and browse button? I believe you can try set it directly in .csproj file, I doubt VS will modify it in this case.

Snowbear
  • 16,924
  • 3
  • 43
  • 67
  • You go into the project's properties then under build you can set the output path. I tried changing the path in the .csproj file but when I open up the project and check the properties I still have a relative path. – Boumbles Mar 22 '11 at 12:35