For VC ++ projects, this is slightly different. You define a file to be imported either at the beginning or at the end of the project. To use this approach, you need to define values for the ForceImportBeforeCppTargetsor properties ForceImportAfterCppTargets. For example, if you want the file to be included at the beginning of the project, you can pass the value on the command line. For example, I just created a dummy VC ++ project called CppTets01. Then I created two example files below.
Before.proj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomTargetInBefore" AfterTargets="Build">
<Message Text="From CustomTargetInBefore" Importance="high"/>
</Target>
</Project>
After.proj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomTargetInAfter" AfterTargets="Build">
<Message Text="From CustomTargetInAfter" Importance="high"/>
</Target>
</Project>
:
msbuild CppTest01.vcxproj
/p:ForceImportBeforeCppTargets="C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\Before.proj";
ForceImportAfterCppTargets="C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\After.proj"
C:\Temp_NET\ThrowAway\CppTest01\CppTest01 > msbuild CppTest01.vcxproj/p: ForceImportBeforeCppTargets = "C:\Temp_NET\ThrowAway\CppTest01\C
ppTest01\Before.proj "; ForceImportAfterCppTargets =" C:\Temp_NET\Throwaway\CppTest01\CppTest01\After.proj "
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 10/18/2010 8:32:55 AM.
Project "C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\CppTest01.vcxproj" on node 1 (default targets).
InitializeBuildStatus:
Creating "Debug\CppTest01.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
All outputs are up-to-date.
All outputs are up-to-date.
ManifestResourceCompile:
All outputs are up-to-date.
Link:
All outputs are up-to-date.
Manifest:
All outputs are up-to-date.
FinalizeBuildStatus:
Deleting file "Debug\CppTest01.unsuccessfulbuild".
Touching "Debug\CppTest01.lastbuildstate".
CustomTargetInBefore:
From CustomTargetInBefore
CustomTargetInAfter:
From CustomTargetInAfter
Done Building Project "C:\Temp\_NET\ThrowAway\CppTest01\CppTest01\CppTest01.vcxproj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.21
, . Custom.Before.Microsoft.Common.targets Custom.Before.Microsoft.Common.targets, , . , , #/VB.NET. . :
- : ImportBefore ImportAfter, V++
# 1 . MSBuild $(PropName), PropName , MSBuild , , , , , , , V++, . .
ImportBefore/ImportAfter
V++ . Microsoft.Cpp.Win32.targets .targets.
<Import Project="$(VCTargetsPath)\Platforms\Win32\ImportBefore\*.targets"
Condition="Exists('$(VCTargetsPath)\Platforms\Win32\ImportBefore')" />
<Import Project="$(VCTargetsPath)\Platforms\Win32\ImportAfter\*.targets"
Condition="Exists('$(VCTargetsPath)\Platforms\Win32\ImportAfter')" />
. %ProgramFiles32%\MSBuild\Microsoft.Cpp\v4.0\Platforms\ .
, , , , .targets, . , V++ . , . . , ,