Can I include a .targets file in a .props property sheet?

孤人 提交于 2020-01-15 07:12:27

问题


I'm developing in C++ using Visual Studio 2012; I have about 25 projects in a solution that all use the same property sheet (.props file). I now need every project that uses said props file to also use a specific .targets file. Instead of editing each of the 25 .vcxproj files to add an import tag (or adding the import via the GUI for each project), I'd like to put an import statement in the .props file they all already use. Is this even possible? I've tried adding the import statement that works in the project file to the .props file just before the closing </Project> tag, and in a new importgroup at that location, and in the existing but empty importgroup labeled for property sheets at the top of the file, and while there are no errors reported, it doesn't actually do anything with the import statement.

Edit: I'm overriding the predefined PostBuildEvent target in order to pass the IgnoreStandardErrorWarningFormat flag to Exec. My postbuild command runs a batch file which runs some unit tests, and the stdout and stderr output from those tests are parsed by VS for errors according to this post. The IgnoreStandardErrorWarningFormat flag disables this parsing.

Here is the contents of my .targets file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="PostBuildEvent" Condition="'$(PostBuildEventUseInBuild)'!='false'">
        <Message Text="Description: %(PostBuildEvent.Message)" Condition="'%    (PostBuildEvent.Message)' != '' and '%(PostBuildEvent.Command)' != ''"/>
        <Exec IgnoreStandardErrorWarningFormat="True" Command="%    (PostBuildEvent.Command)$(_BuildSuffix)" Condition="'%(PostBuildEvent.Command)' != ''"/>
    </Target>
</Project>

来源:https://stackoverflow.com/questions/19436524/can-i-include-a-targets-file-in-a-props-property-sheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!