9

I'm currently using a post build event in my project to copy my assemblies to another directory for debugging purposes. This is local to my machine, and is for debugging purposes only, so I would prefer to have it in a *.csproj.user file instead of a *.csproj file. I tried copying the responsible elements from the *.csproj to the *.csproj.user, but that didn't work.

Edit To clarify, I do not want to put user specific commands in the post-build event in the *.csproj file. Instead, I want to put the post-build event commands in the *.csproj.user file. (From the answers so far, this is looking impossible)

To give more context, it is not a project reference. I am copying my assembly to the directory of the application that loads the assemblies at runtime. (Think plugins)

blachniet
  • 4,323
  • 5
  • 33
  • 34
  • If it is a project dependency you should be able to get it to copy by having it in the references. Why is this a local thing only? can you explain a bit more of the root of your problem? – Neil Jul 27 '12 at 15:10
  • The way I have done plugins in the past is to create a dummy project that depends on your dll's and has an output directory for the plugin. Then you can use the debug tab on the project options to get the thing to start. – Neil Jul 28 '12 at 15:51

4 Answers4

7

The short answer is no, not the way you want to do it :|

The slightly longer answer is sorta. You can in theory have specific build events triggered for individual users, but these would still be in the csproj file. You can run external events on builds and then allow these external events to run depending on what user is running them (as a script).

If this is for debug only I'd just insert them, do your build stuff and pull them out before uploading it to your version control system.

John Mitchell
  • 9,653
  • 9
  • 57
  • 91
  • I was afraid of that. I apparently didn't clarify my question very well, because so far you are the only one to seem to understand what I'm getting at. – blachniet Jul 27 '12 at 15:23
4

Use an if statement and an enviroment variable (in double quotes if required)

if "$(Username)" == "MyUser"
  copy /y $(ProjectDir)memcached.$(ConfigurationName).config $(ProjectDir)memcached.config
Community
  • 1
  • 1
Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
2

You can utilize a custom build target that has a condition triggered by an environment variable. Then only set that variable on your machine.

rerun
  • 25,014
  • 6
  • 48
  • 78
0

Pre-/Post-build events are kept in the project file. VS provides no options.

You can introduce a custom (external) tool to perform such copying though and call it from menu, or macros and call it too.

abatishchev
  • 98,240
  • 88
  • 296
  • 433