4

Right now I'm thinking write the paths to a file in the pre-build event and then read from that file in the code, but I'm wondering if there's an easier more elegant way.

edit: This is sort of a follow up to Help with one step build all projects + installer (.NET + WiX) since I didn't really get an answer to that, seeing if I can get an answer to a simpler question.

Community
  • 1
  • 1
Davy8
  • 30,868
  • 25
  • 115
  • 173

2 Answers2

8

Here's a dirty hack: dump them to a file.

  1. Add an action to the pre-build events to output your solution's path to a file:

    echo $(SolutionDir) > SolutionDirFile.txt

  2. Read the file SolutionDirFile.txt in your C# code.

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
  • Yeah, that's what I was thinking, but was wondering if there was a cleaner solution, but I guess that should work. This answer saves me finding how to write it to a file from the prebuild, so accepted it. – Davy8 Jan 27 '09 at 17:06
  • 1
    At first I was thinking, "Ouch. That's **ugly**." But after an hour of searching, this is the only solution that actually does what I need. +1 – Jake Jan 02 '12 at 20:46
0

This is just a guess, but I think one of the ways you could get this information into the file at compile-time is by using something like PostSharp. Basically, get some sort of preprocessor to get the data for you, and then simply embed it in your assembly.

Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166