2

I want to add a small piece of information such as a software package version I have on my machine to my C# executable.

I want this info pulled on the fly during every build of my program. The info is just 1 line in a text file saved somewhere on C:\

The info needs to be accessible to my program, when I click a button within it, it should display that line of text it grabbed during the build.

Perhaps this could be accomplished by putting the info into a custom environment variable, which gets propagated during a build by adding a before build target. Not sure how to do that, if its even possible. Im using VS2008.

Please share your ideas!

2 Answers2

2

VStudio has the option of performing pre-build steps. In our build, we have a batch file that executes tools that in turn generate a small file of C# which is then built by the build process. It's not very elegant, but has the benefit of simplicity and it works.

John Källén
  • 7,551
  • 31
  • 64
0

If you are the only person to be building this (or everyone building it has this text file in the same location), you could add your text file to your project as a linked item.

This way the file would be included with your project without creating a copy so any updates to it would be propagated to your project.

  1. Right-click the project in solution explorer
  2. Add->Existing Item...
  3. Once you have navigated to your text file, click the down arrow icon at the right edge of the add button and select "Add as Link"

These steps are copied from this answer to a different question. That question was dealing with VS2010, but this should work in VS2008 just the same.

Community
  • 1
  • 1
Sven Grosen
  • 5,616
  • 3
  • 30
  • 52