Background
I am attempting to build a C++ Visual Studio project. My project is Importing an MSBuild .targets file that specifies a single Target, "SetupConanDependencies". This Target uses the conan
tool to install dependencies for a project based on a "conanfile.txt" file located in the project root directory.
The output of this Target consists of several files, including a "conanbuildinfo.props" property file. I can Import the generated .props file in my project in order to tell it how to resolve dependencies that have been installed via conan
.
Here is a stripped down version of my Target definition (I have tested and verified that it does produce a "conanbuildinfo.props" file):
<Target Name="SetupConanDependencies"
Inputs="$(SolutionDir)conanfile.txt"
Outputs="$(OutDir).conan/conanbuildinfo.props"
BeforeTargets="ClCompile">
<Message Importance="High" Text="Installing project dependencies with conan..." />
<Exec Command="conan install $(ProjectDir)conanfile.txt --install-folder=$(OutDir).conan"/>
</Target>
For my question, the only relevant information is that I have a Target that is generating a .props property file. I would like to Import the generated property file in my project before building. However, I also want the Target to run automatically as part of the build process.
Question
I cannot simply Import the generated .props file inside the .targets file, because it has not yet been built by the Target.
<Import Project="$(OutDir).conan/conanbuildinfo.props"/>
<!-- Adding this line after my Target definition results in the following error, because
the file doesn't exist on disk at the time the .targets file is imported. -->
<!-- Error MSB4019 The imported project "D:\CustomBuildToolExample\Debug\.conan\conanbuildinfo.props" was not
found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. -->
Furthermore, from my current understanding of MSBuild, .props files are supposed to be Imported before .targets files. This seems to imply that I cannot Import the .props file that gets created by my Target at all, because by the time the Target generates the .props file, the project has already imported all of the Properties it will use as part of the build process.
Is there a way to include a .props file that is generated by a Target, so that my project will use the properties defined in that .props file as part of its build process?