MSBuild: Evaluating Reserved Properties Using ReadLinesFromFile

I use MSBuild to customize the build process for Visual Studio, WiX, SandCastle, ... projects. To keep it as general as possible, I would like to use text files that define some "project specific" parameters, for example, where the files should be downloaded, which user executables to run, etc.

The text file may look like this: $ (MSBuildProjectDirectory) .... \ Projects \ Project1 \ bin \ Release obj \ $ (Configuration) \ Project1.Files.wxi -in * .dll -id TEST

Each line represents one command or file.

Inside my goals, I use ReadLinesFromFile to get the contents of these files. So far so good!

The problem is that the reserved properties, such as' $ (Configuration), $ (MSBuildProjectDirectory), are not evaluated at the same time, they are simply processed as plain text.

Any ideas on how I could evaluate these $ -local holders without creating a custom task?

Thanks in advance!

Regards, robert.oh.

0
properties msbuild reserved
source share
1 answer

Instead of reading the lines and parsing everything yourself, why not create a separate file (for example, "local.build.config") that has

<PropertyGroup> <someproperty>$(MSBuildProjectDirectory)..\Projects\Project1\bin\Release</someproperty> </PropertyGroup> 

in the file, and then in your real project, import the file with the following line at the top of the assembly:

 <Import Project="local.build.config" Condition="Exists('local.build.config')"/> 

Prevents wheel reuse by letting the MSBuild engine do what it does best.

+1
source share

All Articles