How to make the assembly become obsolete when the text file is modified?

Scenario
My project has a post build phase configured to run a batch file that reads the text file "version.txt". The batch file uses the information in the version.txt file to insert the DLL into the version block using this tool .

A .txt version file is included in my project, which simplifies its modification. It looks something like this:

@set #Description="TankFace Utility Library" @set #FileVersion="0.1.2.0" @set #Comments="" 

Basically, a batch file renames this file to version.bat, calls it, and then renames it back to version.txt.

Problem
When I modify the .txt version file (for example, to increase the version of the file) and then press F7, the assembly is not considered obsolete, so the step after the assembly does not work, so the version of the DLL does not work.

I really want to include the .txt file as input to the assembly, but am not trying to use anything.

If I # include the .txt file from the CPP file in the project, the compiler does not work because it clearly does not understand what “@set” means.

If I add / * ... * / comments around @set commands, then the batch file has some syntax errors, but ultimately succeeds. But this is a bad decision, I think.

So ... how would you do that?

+4
source share
2 answers

This works in VS2005. If you are not using this, some settings may be in different places or with different names.

Add a text file to your project, right-click on it in Solution Explorer and select Properties. Under Configuration Properties> General, verify that the file is not excluded from the assembly. Under Custom Build Step> General, place your existing post build command as the Command Prompt. Make sure you specify the .txt file as the output file. Now F7 should notice the changes in the text file and run the batch file.

+1
source

This may be too hacked, but it may work:

  • Write a quick Perl (etc.) script to verify that version.txt is up to date.
  • If the file has been modified, install this fictitious source code script compiled with your project.
  • Run the script as a pre-build event.

Thus, if the script sees that the file has been modified, it will change another, which will lead to re-assembly.

Hacky, but try if you clean the bottom of the trunk.

0
source

All Articles