10

I need to output the project dll in program files. "$(PROGRAMFILES)\Microsoft..." It is not building in program files, but in the project itself in a folder called "$(PROGRAMFILES)"!

How do I build in program files??

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Kervin Ramen
  • 2,575
  • 2
  • 24
  • 22
  • 1
    I would run very fast and far away from building a project straight into its deployment target. – ProfK Dec 24 '16 at 07:01

5 Answers5

21
  1. In Solution Explorer, right click your project, click "Unload Project"
  2. After the project unloads, right click on it again, click "Edit MYPROJECT.csproj"
  3. In the XML editor window that opens, change <OutputPath> elements to <OutputPath>$(ProgramFiles)</OutputPath> -- either all of them, or only those for the configurations that interest you
  4. Save and close
  5. Right click on project again, choose "Reload Project"
  6. Done!
Jon
  • 428,835
  • 81
  • 738
  • 806
3

And if you just made a new environment variable, reload visual studio as well, else it will use 'C:\' instead of your variable content.

The E
  • 31
  • 1
1

This sounds like a good case for a post-build event that copies the project output to the folder you want:

copy $(TargetPath) $(PROGRAMFILES)\Microsoft...

JeffSahol
  • 971
  • 8
  • 19
  • 2
    That's going to end up with a build in the default location, probably $(ProjectDir)\bin\$(Configuration), then a copy. And one reason to move the output dir is for speed! – Anthony Mastrean May 17 '11 at 18:24
0

right click on project select properties. Select Build tab you have output section

In output path give the specific path for you program file/microsoft. This should work. I Tested it.

Praneeth
  • 2,527
  • 5
  • 30
  • 47
  • I need the variable tough. As on x64 machines the path is different. "Program Files (x86)" on x64 and "Program Files" on x86 machines (as it is build for 32-bit) – Kervin Ramen Apr 05 '11 at 06:14
0

You need to open the csproj file in a text editor and manually enter your environment variables in the OutputPath section. Visual Studio escapes the '$', '(' and ')' when you try to do this from the IDE.

PhilMY
  • 2,621
  • 21
  • 29