How can I read the OutputDirectory property from a vcproj (2008) file in a wrapper script?

464 Views Asked by At

I am trying to write an MSBuild wrapper script that builds a vcproj (well, a solution containing vcproj files) and then copies the output of a particular vcproj file into a special "package" directory that is in turn published out to a file share. I need to do this for several Configurations and Platforms (Debug, Release, Win32, x64). Ideally, I would like to be able to read the "OutputDirectory" from the vcproj file for a particular Configuration/Platform so that I can then copy its contents. With csproj files, this is simple, as I can "import" the csproj file into my MSBuild wrapper script and then read the "OutputPath" property. Unfortunately, I cannot import vcproj (for VS 2008) files into an MSBuild script, as they are not MSBuild-compatible, so that approach does not work.

Does anyone know a way that I can read the value of the "OutputDirectory" property form a vcproj file? Please note that I do not want to use XPath and roll this myself, as the raw OutputDirectory property looks something like "$(ProjectDir)\bin\$(ConfigurationName)\$(PlatformName)". I want all those macros expanded for me, just as would be done when running vcbuild.

1

There are 1 best solutions below

0
On

You can extract OutputPath for each Configuration in separate property files like Debug.Properties, Release.Properties, etc and then import appropriate one using directive in both vcproj and msbuild script files.

<Import Project="Debug.Properties" />

Or Dynamically depends on Configuration:

<Import Project="$(ConfigurationBasedPropertiesFile)" />

Set value of the property $(ConfigurationBasedPropertiesFile) considering current Configuration