Reputation: 373
I've been trying to write C# code that retrieves data from a file in compilation-time, and not in run-time. The thing is that I need to get a version of a file that exists in my machine, but not in machines that would run this DLL. (The version can be changed tomorrow, so I want to able to retrieve that dynamically). In run-time, those machines have no access to the file, and that's why I need to get this data before. Anyone as an idea how to do so ? Thanks.
Upvotes: 1
Views: 458
Reputation: 5320
If you want to do something before or after a project is built you can write a command line statement in pre-build event command line
or in post-build command line
in Build Events
section of project properties.
Upvotes: 0
Reputation: 69260
The C# code that you are compiling will not be run during the compilation.
You should make a pre-build step that extracts the version information. That custom build step could in itself be a C# program if you want. Make that program output a small .cs file containing the version number of the dll and include that .cs file in the source for the main program.
Upvotes: 2