Microsoft.Common.targets 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. <Project DefaultTargets="Build" InitialTargets="_CheckForInvalidConfigurationAndPlatform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2. <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="'$(MicrosoftCommonPropsHasBeenImported)' != 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  3. <PropertyGroup>
  4. <ImportByWildcardBeforeMicrosoftCommonTargets Condition="'$(ImportByWildcardBeforeMicrosoftCommonTargets)' == ''">true</ImportByWildcardBeforeMicrosoftCommonTargets>
  5. <ImportByWildcardAfterMicrosoftCommonTargets Condition="'$(ImportByWildcardAfterMicrosoftCommonTargets)' == ''">true</ImportByWildcardAfterMicrosoftCommonTargets>
  6. </PropertyGroup>
  7. <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*"
  8. Condition="'$(ImportByWildcardBeforeMicrosoftCommonTargets)' == 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/>
  9. <Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')"/>
  10. <PropertyGroup>
  11. <OutputType Condition="'$(OutputType)' == ''">Exe</OutputType>
  12. <TargetExt Condition="'$(OutputType)' == 'Winexe'">.exe</TargetExt>
  13. <TargetExt Condition="'$(OutputType)' == 'Exe'">.exe</TargetExt>
  14. <TargetExt Condition="'$(OutputType)' == 'Library'">.dll</TargetExt>
  15. <TargetExt Condition="'$(OutputType)' == 'Netmodule'">.netmodule</TargetExt>
  16. </PropertyGroup>
  17. <PropertyGroup>
  18. <ProjectDir Condition="'$(ProjectDir)' == ''">$(MSBuildProjectDirectory)\</ProjectDir>
  19. </PropertyGroup>
  20. <!-- MSBuild defines this even outside of VS, and F# projects depend on it -->
  21. <PropertyGroup>
  22. <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
  23. </PropertyGroup>
  24. <PropertyGroup>
  25. <AssemblyName Condition="'$(AssemblyName)' == ''">$(MSBuildProjectName)</AssemblyName>
  26. <OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>
  27. <OutputPath Condition=" '$(Platform)'=='' and '$(Configuration)'=='' and '$(OutputPath)'=='' ">bin\Debug\</OutputPath>
  28. <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
  29. <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.0</TargetFrameworkVersion>
  30. <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$(TargetFrameworkProfile)' != ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
  31. <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
  32. </PropertyGroup>
  33. <PropertyGroup>
  34. <OutDir Condition="'$(OutDir)' == ''">$(OutputPath)</OutDir>
  35. <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
  36. <_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
  37. <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  38. <ConfigurationName Condition="'$(ConfigurationName)' == ''">$(Configuration)</ConfigurationName>
  39. <_OriginalPlatform>$(Platform)</_OriginalPlatform>
  40. <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  41. <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
  42. </PropertyGroup>
  43. <!-- in MSBuild, these properties are set in a separate file that is only imported for .NETFramework -->
  44. <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
  45. <AddAdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == ''">true</AddAdditionalExplicitAssemblyReferences>
  46. <AdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == 'true' and '$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.0'">System.Core;$(AdditionalExplicitAssemblyReferences)</AdditionalExplicitAssemblyReferences>
  47. </PropertyGroup>
  48. <PropertyGroup>
  49. <SkipCopyUnchangedFiles Condition="'$(SkipCopyUnchangedFiles)' == ''">true</SkipCopyUnchangedFiles>
  50. </PropertyGroup>
  51. <PropertyGroup>
  52. <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">obj\</BaseIntermediateOutputPath>
  53. <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' != '' and !HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
  54. <CleanFile Condition="'$(CleanFile)'==''">$(MSBuildProjectFile).FilesWrittenAbsolute.txt</CleanFile>
  55. </PropertyGroup>
  56. <PropertyGroup Condition="'$(IntermediateOutputPath)' == ''">
  57. <IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU'">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
  58. <IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
  59. </PropertyGroup>
  60. <PropertyGroup>
  61. <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' != '' and !HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
  62. </PropertyGroup>
  63. <ItemGroup>
  64. <IntermediateAssembly Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)" />
  65. <!-- creating this as a item to use FullPath on it, to build TargetPath -->
  66. <_OutDirItem Include="$(OutDir)"/>
  67. </ItemGroup>
  68. <PropertyGroup>
  69. <TargetName Condition="'$(TargetName)' == '' ">$(AssemblyName)</TargetName>
  70. <TargetFileName Condition="'$(TargetFileName)' == '' ">$(TargetName)$(TargetExt)</TargetFileName>
  71. <TargetDir Condition=" '$(TargetDir)' == '' ">@(_OutDirItem->'%(FullPath)')</TargetDir>
  72. <TargetPath Condition=" '$(TargetPath)' == '' ">@(_OutDirItem->'%(FullPath)\$(TargetFileName)')</TargetPath>
  73. <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildProjectFullPath);$(MSBuildToolsPath)\Microsoft.Common.targets</MSBuildAllProjects>
  74. <KeyOriginatorFile Condition=" '$(SignAssembly)' == 'true' ">$(AssemblyOriginatorKeyFile)</KeyOriginatorFile>
  75. <TargetingClr2Framework Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') and ('$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5')">true</TargetingClr2Framework>
  76. </PropertyGroup>
  77. <Target Name="_CheckForInvalidConfigurationAndPlatform">
  78. <Error Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' != 'true'"
  79. Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
  80. <Warning Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' == 'true'"
  81. Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
  82. <!-- If OutDir is specified via the command line, then the earlier check
  83. to add a trailing slash won't have any affect, so error here. -->
  84. <Error
  85. Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')"
  86. Text="OutDir property must end with a slash."/>
  87. </Target>
  88. <PropertyGroup>
  89. <PrepareForBuildDependsOn>AssignLinkMetadata</PrepareForBuildDependsOn>
  90. </PropertyGroup>
  91. <Target Name="PrepareForBuild" DependsOnTargets="$(PrepareForBuildDependsOn)">
  92. <Message Importance="High" Text="Configuration: $(Configuration) Platform: $(Platform)"/>
  93. <!-- Look for app.config, if $(AppConfig) is specified, then use that. Else look in
  94. @(None) and @(Content) -->
  95. <CreateItem Include="$(AppConfig)" Condition="'$(AppConfig)' != ''"
  96. AdditionalMetadata="TargetPath=$(TargetFileName).config">
  97. <Output TaskParameter="Include" ItemName="AppConfigWithTargetPath" />
  98. </CreateItem>
  99. <FindAppConfigFile PrimaryList="@(None)" SecondaryList="@(Content)" TargetPath="$(TargetFileName).config"
  100. Condition="'$(AppConfig)' == ''">
  101. <Output TaskParameter="AppConfigFile" ItemName="AppConfigWithTargetPath"/>
  102. </FindAppConfigFile>
  103. <MakeDir
  104. Directories="$(OutDir);$(IntermediateOutputPath);@(DocFileItem->'%(RelativeDir)')"
  105. />
  106. </Target>
  107. <Target Name="AssignLinkMetadata">
  108. <AssignLinkMetadata Items="@(EmbeddedResource)" Condition="'@(EmbeddedResource)' != '' and '%(EmbeddedResource.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)'">
  109. <Output TaskParameter="OutputItems" ItemName="_EmbeddedResourceWithLinkAssigned" />
  110. </AssignLinkMetadata>
  111. <ItemGroup>
  112. <EmbeddedResource Remove="@(_EmbeddedResourceWithLinkAssigned)" />
  113. <EmbeddedResource Include="@(_EmbeddedResourceWithLinkAssigned)" />
  114. <_EmbeddedResourceWithLinkAssigned Remove="@(_EmbeddedResourceWithLinkAssigned)" />
  115. </ItemGroup>
  116. </Target>
  117. <PropertyGroup>
  118. <GetFrameworkPathsDependsOn />
  119. </PropertyGroup>
  120. <Target Name="GetFrameworkPaths"
  121. Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework'"
  122. DependsOnTargets="$(GetFrameworkPathsDependsOn)">
  123. <GetFrameworkPath>
  124. <Output Condition="'$(TargetFrameworkVersion)' == 'v4.5' or '$(TargetFrameworkVersion)' == 'v4.5.1' or '$(TargetFrameworkVersion)' == 'v4.5.2' or '$(TargetFrameworkVersion)' == 'v4.6' or '$(TargetFrameworkVersion)' == 'v4.6.1' or '$(TargetFrameworkVersion)' == 'v4.6.2'"
  125. TaskParameter="FrameworkVersion45Path"
  126. ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
  127. <Output Condition="'$(TargetFrameworkVersion)' == 'v4.0'"
  128. TaskParameter="FrameworkVersion40Path"
  129. ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
  130. <Output Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
  131. TaskParameter="FrameworkVersion35Path"
  132. ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
  133. <Output Condition="'$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'"
  134. TaskParameter="FrameworkVersion30Path"
  135. ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
  136. <Output Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'"
  137. TaskParameter="FrameworkVersion20Path"
  138. ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
  139. </GetFrameworkPath>
  140. <CreateProperty Value="@(_CombinedTargetFrameworkDirectoriesItem)">
  141. <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
  142. </CreateProperty>
  143. <Warning Text="TargetFrameworkVersion '$(TargetFrameworkVersion)' not supported by this toolset (ToolsVersion: $(MSBuildToolsVersion))."
  144. Condition="'$(TargetFrameworkVersion)' != 'v4.6.2' and '$(TargetFrameworkVersion)' != 'v4.6.1' and '$(TargetFrameworkVersion)' != 'v4.6' and '$(TargetFrameworkVersion)' != 'v4.5.2' and '$(TargetFrameworkVersion)' != 'v4.5.1' and '$(TargetFrameworkVersion)' != 'v4.5' and '$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
  145. </Target>
  146. <PropertyGroup>
  147. <GetReferenceAssemblyPathsDependsOn />
  148. </PropertyGroup>
  149. <Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)">
  150. <!-- in case of .NETFramework, $(TargetFrameworkDirectory) would have been set by
  151. GetFrameworkPaths, if it hasn't been changed, then clear it, to avoid duplicates -->
  152. <CreateProperty Value="" Condition="'@(_CombinedTargetFrameworkDirectoriesItem)' == '$(TargetFrameworkDirectory)'">
  153. <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
  154. </CreateProperty>
  155. <GetReferenceAssemblyPaths
  156. Condition="'$(TargetFrameworkMoniker)' != '' and '$(_TargetFrameworkDirectories)' == ''"
  157. TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
  158. RootPath="$(TargetFrameworkRootPath)">
  159. <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
  160. <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
  161. <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName"/>
  162. </GetReferenceAssemblyPaths>
  163. <!-- Remove duplicates. -->
  164. <ItemGroup>
  165. <_TargetFrameworkDirectories Include="$(_TargetFrameworkDirectories);$(TargetFrameworkDirectory)" KeepDuplicates="false" />
  166. </ItemGroup>
  167. <PropertyGroup>
  168. <TargetFrameworkDirectory>@(_TargetFrameworkDirectories)</TargetFrameworkDirectory>
  169. </PropertyGroup>
  170. <ItemGroup Condition="'$(ImplicitlyExpandDesignTimeFacades)' == 'true'">
  171. <DesignTimeFacadeDirectoryRoots Include="$(TargetFrameworkDirectory)" />
  172. <DesignTimeFacadeDirectories Include="%(DesignTimeFacadeDirectoryRoots.Identity)\Facades\" Condition="Exists('%(DesignTimeFacadeDirectoryRoots.Identity)\Facades\')" />
  173. <_DesignTimeFacadeAssemblies Include="%(DesignTimeFacadeDirectories.Identity)\*.dll"/>
  174. </ItemGroup>
  175. <PropertyGroup Condition="'@(DesignTimeFacadeDirectories)' != ''">
  176. <TargetFrameworkDirectory>$(TargetFrameworkDirectory);@(DesignTimeFacadeDirectories)</TargetFrameworkDirectory>
  177. </PropertyGroup>
  178. </Target>
  179. <PropertyGroup>
  180. <AllowedReferenceAssemblyFileExtensions Condition=" '$(AllowedReferenceAssemblyFileExtensions)' == '' ">
  181. .exe;
  182. .dll
  183. </AllowedReferenceAssemblyFileExtensions>
  184. <AllowedReferenceRelatedFileExtensions Condition=" '$(AllowedReferenceRelatedFileExtensions)' == '' ">
  185. .exe.mdb;
  186. .dll.mdb;
  187. .pdb;
  188. .xml
  189. </AllowedReferenceRelatedFileExtensions>
  190. <AssemblySearchPaths Condition="'$(AssemblySearchPaths)' == ''">
  191. {CandidateAssemblyFiles};
  192. $(ReferencePath);
  193. @(AdditionalReferencePath);
  194. {HintPathFromItem};
  195. {TargetFrameworkDirectory};
  196. {PkgConfig};
  197. {GAC};
  198. {RawFileName};
  199. $(OutDir)
  200. </AssemblySearchPaths>
  201. <ResolveReferencesDependsOn>
  202. BeforeResolveReferences;
  203. ResolveProjectReferences;
  204. ResolveAssemblyReferences;
  205. AfterResolveReferences
  206. </ResolveReferencesDependsOn>
  207. <ResolveAssemblyReferencesDependsOn>
  208. GetFrameworkPaths;
  209. GetReferenceAssemblyPaths;
  210. PrepareForBuild
  211. </ResolveAssemblyReferencesDependsOn>
  212. </PropertyGroup>
  213. <PropertyGroup Condition="'$(TargetFrameworkMoniker)' != ''">
  214. <TargetFrameworkMonikerAssemblyAttributesPath Condition="'$(TargetFrameworkMonikerAssemblyAttributesPath)' == ''">$(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttribute$(DefaultLanguageSourceExtension)</TargetFrameworkMonikerAssemblyAttributesPath>
  215. <GenerateTargetFrameworkAttribute Condition="'$(GenerateTargetFrameworkAttribute)' == '' and '$(TargetFrameworkMoniker)'
  216. != '' and '$(TargetingClr2Framework)' != 'true'">true</GenerateTargetFrameworkAttribute>
  217. </PropertyGroup>
  218. <ItemGroup Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'">
  219. <FileWrites Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
  220. </ItemGroup>
  221. <Target Name="_GenerateTargetFrameworkMonikerAttribute"
  222. DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths"
  223. Inputs="$(MSBuildToolsPath)\Microsoft.Common.targets"
  224. Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)">
  225. <WriteLinesToFile
  226. File="$(TargetFrameworkMonikerAssemblyAttributesPath)"
  227. Lines="$(TargetFrameworkMonikerAssemblyAttributeText)"
  228. Overwrite="true"
  229. ContinueOnError="true"
  230. Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''"
  231. />
  232. </Target>
  233. <Target Name="GenerateTargetFrameworkMonikerAttribute"
  234. DependsOnTargets="_GenerateTargetFrameworkMonikerAttribute"
  235. Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'">
  236. <ItemGroup Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''">
  237. <Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/>
  238. </ItemGroup>
  239. </Target>
  240. <Target Name="ResolveReferences" DependsOnTargets="$(ResolveReferencesDependsOn)"/>
  241. <Target Name="BeforeResolveReferences" />
  242. <Target Name="AfterResolveReferences" />
  243. <Target Name="ResolveAssemblyReferences" DependsOnTargets="$(ResolveAssemblyReferencesDependsOn)">
  244. <CreateItem Include="@(Reference)" Exclude="$(AdditionalExplicitAssemblyReferences)">
  245. <Output TaskParameter="Include" ItemName="_Reference"/>
  246. </CreateItem>
  247. <CreateItem Include="$(AdditionalExplicitAssemblyReferences)">
  248. <Output TaskParameter="Include" ItemName="_Reference"/>
  249. </CreateItem>
  250. <ResolveAssemblyReference
  251. Assemblies="@(_Reference)"
  252. AssemblyFiles="@(ChildProjectReferences);@(_ExplicitReference)"
  253. SearchPaths="$(AssemblySearchPaths)"
  254. CandidateAssemblyFiles="@(Content);@(None)"
  255. TargetFrameworkDirectories="$(TargetFrameworkDirectory)"
  256. AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
  257. AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
  258. FindDependencies="true"
  259. FindSatellites="true"
  260. FindRelatedFiles="true"
  261. TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
  262. TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)"
  263. TargetFrameworkVersion="$(TargetFrameworkVersion)"
  264. >
  265. <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
  266. <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
  267. <Output TaskParameter="ResolvedDependencyFiles" ItemName="ReferenceDependencyPaths"/>
  268. <Output TaskParameter="RelatedFiles" ItemName="_ReferenceRelatedPaths"/>
  269. <Output TaskParameter="SatelliteFiles" ItemName="ReferenceSatellitePaths"/>
  270. <Output TaskParameter="CopyLocalFiles" ItemName="ReferenceCopyLocalPaths"/>
  271. <Output TaskParameter="DependsOnSystemRuntime" PropertyName="DependsOnSystemRuntime"/>
  272. <!-- FIXME: backwards compatibility -->
  273. <Output TaskParameter="ResolvedDependencyFiles" ItemName="_ResolvedDependencyFiles"/>
  274. </ResolveAssemblyReference>
  275. </Target>
  276. <Target
  277. Name="AssignProjectConfiguration"
  278. Condition="'@(ProjectReference)' != ''">
  279. <!-- assign configs if building a solution file -->
  280. <AssignProjectConfiguration
  281. ProjectReferences = "@(ProjectReference)"
  282. SolutionConfigurationContents = "$(CurrentSolutionConfigurationContents)"
  283. Condition="$(CurrentSolutionConfigurationContents) != '' and ('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true')">
  284. <Output TaskParameter = "AssignedProjects" ItemName = "ProjectReferenceWithConfiguration"/>
  285. </AssignProjectConfiguration>
  286. <!-- Else, just -->
  287. <CreateItem Include="@(ProjectReference)" Condition="$(CurrentSolutionConfigurationContents) == '' or ('$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true')">
  288. <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfiguration"/>
  289. </CreateItem>
  290. </Target>
  291. <!-- Split projects into 2 lists
  292. ProjectReferenceWithConfigurationExistent: Projects existent on disk
  293. ProjectReferenceWithConfigurationNonExistent: Projects non-existent on disk -->
  294. <Target Name="SplitProjectReferencesByExistent"
  295. DependsOnTargets="AssignProjectConfiguration">
  296. <CreateItem Include="@(ProjectReferenceWithConfiguration)" Condition="'@(ProjectReferenceWithConfiguration)' != ''">
  297. <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationExistent"
  298. Condition="Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
  299. <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationNonExistent"
  300. Condition="!Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
  301. </CreateItem>
  302. </Target>
  303. <Target
  304. Name="ResolveProjectReferences"
  305. DependsOnTargets="SplitProjectReferencesByExistent"
  306. >
  307. <!-- If building from a .sln.proj or from IDE, then referenced projects have already
  308. been built, so just get the target paths -->
  309. <MSBuild
  310. Projects="@(ProjectReferenceWithConfigurationExistent)"
  311. Targets="GetTargetPath"
  312. Properties="%(ProjectReferenceWithConfigurationExistent.SetConfiguration); %(ProjectReferenceWithConfigurationExistent.SetPlatform)"
  313. Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and ('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true')">
  314. <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" Condition="'%(ProjectReferenceWithConfigurationExistent.ReferenceOutputAssembly)' != 'false'"/>
  315. </MSBuild>
  316. <!-- Building a project directly, build the referenced the projects also -->
  317. <MSBuild
  318. Projects="@(ProjectReferenceWithConfigurationExistent)"
  319. Properties="%(ProjectReferenceWithConfigurationExistent.SetConfiguration); %(ProjectReferenceWithConfigurationExistent.SetPlatform)"
  320. Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' ">
  321. <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" Condition="'%(ProjectReferenceWithConfigurationExistent.ReferenceOutputAssembly)' != 'false'"/>
  322. </MSBuild>
  323. <Warning Text="Referenced Project %(ProjectReferenceWithConfigurationNonExistent.Identity) not found, ignoring."
  324. Condition="'@(ProjectReferenceWithConfigurationNonExistent)' != ''"/>
  325. </Target>
  326. <Target Name = "CopyFilesMarkedCopyLocal">
  327. <Copy
  328. SourceFiles="@(ReferenceCopyLocalPaths)"
  329. DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
  330. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  331. <Output TaskParameter = "DestinationFiles" ItemName = "FileWritesShareable"/>
  332. </Copy>
  333. </Target>
  334. <Target Name="_ComputeNonExistentFileProperty" Condition='false'>
  335. <CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
  336. <Output TaskParameter="Value" PropertyName="NonExistentFile"/>
  337. </CreateProperty>
  338. </Target>
  339. <PropertyGroup>
  340. <BuildDependsOn>
  341. BuildOnlySettings;
  342. BeforeBuild;
  343. CoreBuild;
  344. AfterBuild
  345. </BuildDependsOn>
  346. </PropertyGroup>
  347. <Target Name="BuildOnlySettings"/>
  348. <Target Name="BeforeBuild"/>
  349. <Target Name="AfterBuild"/>
  350. <Target Name="Build" DependsOnTargets="$(BuildDependsOn)" Outputs="$(TargetPath)"/>
  351. <PropertyGroup>
  352. <CoreBuildDependsOn>
  353. PrepareForBuild;
  354. GetFrameworkPaths;
  355. GetReferenceAssemblyPaths;
  356. PreBuildEvent;
  357. ResolveReferences;
  358. CopyFilesMarkedCopyLocal;
  359. PrepareResources;
  360. Compile;
  361. PrepareForRun;
  362. DeployOutputFiles;
  363. _RecordCleanFile;
  364. PostBuildEvent
  365. </CoreBuildDependsOn>
  366. </PropertyGroup>
  367. <Target
  368. Name="CoreBuild"
  369. DependsOnTargets="$(CoreBuildDependsOn)"
  370. Outputs="$(OutDir)$(AssemblyName)$(TargetExt)">
  371. <OnError ExecuteTargets="_TimestampAfterCompile;PostBuildEvent"
  372. Condition=" '$(RunPostBuildEvent)' == 'Always' or '$(RunPostBuildEvent)' == 'OnOutputUpdated'"/>
  373. <OnError ExecuteTargets="_RecordCleanFile" />
  374. </Target>
  375. <PropertyGroup>
  376. <CompileDependsOn>
  377. ResolveReferences;
  378. GenerateTargetFrameworkMonikerAttribute;
  379. BeforeCompile;
  380. _TimestampBeforeCompile;
  381. CoreCompile;
  382. _TimestampAfterCompile;
  383. AfterCompile
  384. </CompileDependsOn>
  385. </PropertyGroup>
  386. <Target Name="BeforeCompile" />
  387. <Target Name="AfterCompile" />
  388. <Target Name="Compile" DependsOnTargets="$(CompileDependsOn)"/>
  389. <PropertyGroup>
  390. <PrepareForRunDependsOn>
  391. DeployOutputFiles
  392. </PrepareForRunDependsOn>
  393. </PropertyGroup>
  394. <Target Name="PrepareForRun" DependsOnTargets="$(PrepareForRunDependsOn)"/>
  395. <PropertyGroup>
  396. <PrepareResourcesDependsOn>
  397. AssignTargetPaths;
  398. SplitResourcesByCulture;
  399. CreateManifestResourceNames;
  400. CopyNonResxEmbeddedResources;
  401. GenerateResources;
  402. GenerateSatelliteAssemblies;
  403. CompileLicxFiles
  404. </PrepareResourcesDependsOn>
  405. </PropertyGroup>
  406. <Target Name="PrepareResources" DependsOnTargets="$(PrepareResourcesDependsOn)" />
  407. <Target Name="SplitResourcesByCulture" DependsOnTargets="AssignTargetPaths">
  408. <!-- Extract .licx files into @(LicxFiles) -->
  409. <CreateItem Include="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' == '.licx'">
  410. <Output TaskParameter="Include" ItemName="LicxFiles"/>
  411. </CreateItem>
  412. <!-- Split *remaining* resource files into various groups.. -->
  413. <AssignCulture Files="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' != '.licx'">
  414. <Output TaskParameter="AssignedFilesWithNoCulture" ItemName="ResourcesWithNoCulture"/>
  415. <Output TaskParameter="AssignedFilesWithCulture" ItemName="ResourcesWithCulture"/>
  416. </AssignCulture>
  417. <CreateItem Include="@(ResourcesWithNoCulture)" Condition="'%(Extension)' == '.resx'">
  418. <Output TaskParameter="Include" ItemName="ResxWithNoCulture"/>
  419. </CreateItem>
  420. <CreateItem Include="@(ResourcesWithNoCulture)" Condition="'%(Extension)' != '.resx'">
  421. <Output TaskParameter="Include" ItemName="NonResxWithNoCulture"/>
  422. </CreateItem>
  423. <CreateItem Include="@(ResourcesWithCulture)" Condition="'%(Extension)' == '.resx'">
  424. <Output TaskParameter="Include" ItemName="ResxWithCulture"/>
  425. </CreateItem>
  426. <CreateItem Include="@(ResourcesWithCulture)" Condition="'%(Extension)' != '.resx'">
  427. <Output TaskParameter="Include" ItemName="NonResxWithCulture"/>
  428. </CreateItem>
  429. </Target>
  430. <!-- Copy non-resx resources to their manifest resource names, this is what the compiler expects -->
  431. <Target Name = "CopyNonResxEmbeddedResources"
  432. Condition = "'@(NonResxWithCulture)' != '' or '@(NonResxWithNoCulture)' != '' or '@(ManifestNonResxWithCulture)' != '' or '@(ManifestNonResxWithNoCulture)' != ''">
  433. <MakeDir Directories="$(IntermediateOutputPath)%(ManifestNonResxWithCulture.Culture)"/>
  434. <Copy SourceFiles = "@(NonResxWithCulture)"
  435. DestinationFiles = "@(ManifestNonResxWithCulture->'$(IntermediateOutputPath)%(Identity)')"
  436. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  437. <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithCultureOnDisk"/>
  438. <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
  439. </Copy>
  440. <Copy SourceFiles = "@(NonResxWithNoCulture)"
  441. DestinationFiles = "@(ManifestNonResxWithNoCulture->'$(IntermediateOutputPath)%(Identity)')"
  442. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  443. <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithNoCultureOnDisk"/>
  444. <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
  445. </Copy>
  446. </Target>
  447. <Target Name = "GenerateResources">
  448. <GenerateResource
  449. Sources = "@(ResxWithNoCulture)"
  450. UseSourcePath = "true"
  451. OutputResources = "@(ManifestResourceWithNoCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
  452. Condition = "'@(ResxWithNoCulture)' != '' ">
  453. <Output TaskParameter = "OutputResources" ItemName = "ManifestResourceWithNoCulture"/>
  454. <Output TaskParameter = "FilesWritten" ItemName = "FileWrites"/>
  455. </GenerateResource>
  456. <GenerateResource
  457. Sources = "@(ResxWithCulture)"
  458. UseSourcePath = "true"
  459. OutputResources = "@(ManifestResourceWithCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
  460. Condition = "'@(ResxWithCulture)' != '' ">
  461. <Output TaskParameter = "OutputResources" ItemName = "ManifestResourceWithCulture"/>
  462. <Output TaskParameter = "FilesWritten" ItemName = "FileWrites"/>
  463. </GenerateResource>
  464. </Target>
  465. <Target Name="GenerateSatelliteAssemblies"
  466. Inputs="@(ManifestResourceWithCulture);@(ManifestNonResxWithCultureOnDisk)"
  467. Outputs="$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll" >
  468. <!-- @(NonResxWithCulture) - rename files to ManifestNon.. and then use for AL -->
  469. <MakeDir Directories = "$(IntermediateOutputPath)%(ManifestResourceWithCulture.Culture)" Condition = "'@(ManifestResourceWithCulture)' != ''" />
  470. <MakeDir Directories = "$(IntermediateOutputPath)%(ManifestNonResxWithCultureOnDisk.Culture)" Condition = "'@(ManifestNonResxWithCultureOnDisk)' != ''" />
  471. <AL
  472. Culture = "%(Culture)"
  473. DelaySign="$(DelaySign)"
  474. EmbedResources = "@(ManifestResourceWithCulture);@(ManifestNonResxWithCultureOnDisk)"
  475. KeyFile="$(KeyOriginatorFile)"
  476. ToolExe="$(AlToolExe)"
  477. ToolPath="$(AlToolPath)"
  478. OutputAssembly = "$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll" >
  479. <Output TaskParameter="OutputAssembly" ItemName="FileWrites"/>
  480. </AL>
  481. <CreateItem
  482. Include = "$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll"
  483. AdditionalMetadata = "Culture=%(Culture)"
  484. Condition = "'@(ManifestResourceWithCulture)' != '' or '@(ManifestNonResxWithCultureOnDisk)' != ''">
  485. <Output TaskParameter = "Include" ItemName = "IntermediateSatelliteAssemblies" />
  486. </CreateItem>
  487. </Target>
  488. <PropertyGroup>
  489. <CompileLicxFilesDependsOn></CompileLicxFilesDependsOn>
  490. </PropertyGroup>
  491. <Target Name = "CompileLicxFiles"
  492. Condition = "'@(LicxFiles)' != ''"
  493. DependsOnTargets = "$(CompileLicxFilesDependsOn)"
  494. Outputs = "$(IntermediateOutputPath)$(TargetFileName).licenses">
  495. <LC
  496. Sources = "@(LicxFiles)"
  497. LicenseTarget = "$(TargetFileName)"
  498. OutputDirectory = "$(IntermediateOutputPath)"
  499. OutputLicense = "$(IntermediateOutputPath)$(TargetFileName).licenses"
  500. ReferencedAssemblies = "@(ReferencePath);@(ReferenceDependencyPaths)"
  501. ToolPath = "$(LCToolPath)"
  502. ToolExe = "$(LCToolExe)">
  503. <Output TaskParameter="OutputLicense" ItemName="CompiledLicenseFile"/>
  504. <Output TaskParameter="OutputLicense" ItemName="FileWrites"/>
  505. </LC>
  506. </Target>
  507. <!-- Assign target paths to files that will need to be copied along with the project -->
  508. <Target Name = "AssignTargetPaths">
  509. <AssignTargetPath Files="@(None)" RootFolder="$(MSBuildProjectDirectory)">
  510. <Output TaskParameter="AssignedFiles" ItemName="NoneWithTargetPath"/>
  511. </AssignTargetPath>
  512. <AssignTargetPath Files="@(Content)" RootFolder="$(MSBuildProjectDirectory)">
  513. <Output TaskParameter="AssignedFiles" ItemName="ContentWithTargetPath"/>
  514. </AssignTargetPath>
  515. <AssignTargetPath Files="@(EmbeddedResource)" RootFolder="$(MSBuildProjectDirectory)">
  516. <Output TaskParameter="AssignedFiles" ItemName="EmbeddedResourceWithTargetPath"/>
  517. </AssignTargetPath>
  518. </Target>
  519. <Target Name="DeployOutputFiles"
  520. DependsOnTargets="PrepareResources;CoreCompile;_CopyDeployFilesToOutputDirectory;_CopyAppConfigFile">
  521. <Copy
  522. SourceFiles="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
  523. Condition="'$(OutDir)' != '' and Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')"
  524. DestinationFolder="$(OutDir)"
  525. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" >
  526. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  527. </Copy>
  528. <Copy
  529. SourceFiles="$(IntermediateOutputPath)$(AssemblyName).pdb"
  530. Condition="'$(OutDir)' != '' and Exists('$(IntermediateOutputPath)$(AssemblyName).pdb')"
  531. DestinationFolder="$(OutDir)"
  532. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" >
  533. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  534. </Copy>
  535. <Copy SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != '' and Exists ('@(IntermediateAssembly)')" DestinationFolder="$(OutDir)" SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  536. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  537. </Copy>
  538. <Copy
  539. SourceFiles = "@(IntermediateSatelliteAssemblies)"
  540. DestinationFiles = "@(IntermediateSatelliteAssemblies->'$(OutDir)\%(Culture)\$(AssemblyName).resources.dll')"
  541. Condition = "'@(IntermediateSatelliteAssemblies)' != ''"
  542. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  543. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  544. </Copy>
  545. </Target>
  546. <Target Name="_CopyDeployFilesToOutputDirectory"
  547. DependsOnTargets="GetCopyToOutputDirectoryItems;
  548. _CopyDeployFilesToOutputDirectoryAlways;
  549. _CopyDeployFilesToOutputDirectoryPreserveNewest"/>
  550. <Target Name="_CopyDeployFilesToOutputDirectoryPreserveNewest"
  551. Condition="'@(ItemsToCopyToOutputDirectoryPreserveNewest)' != ''"
  552. Inputs="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
  553. Outputs="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
  554. <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
  555. DestinationFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')"
  556. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
  557. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  558. </Copy>
  559. </Target>
  560. <!-- Copy if newer -->
  561. <Target Name="_CopyDeployFilesToOutputDirectoryAlways"
  562. Condition="'@(ItemsToCopyToOutputDirectoryAlways)' != ''">
  563. <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryAlways)"
  564. DestinationFiles="@(ItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')">
  565. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  566. </Copy>
  567. </Target>
  568. <Target Name="_CopyAppConfigFile" Condition="'@(AppConfigWithTargetPath)' != ''"
  569. Inputs="@(AppConfigWithTargetPath)"
  570. Outputs="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
  571. <Copy SourceFiles="@(AppConfigWithTargetPath)"
  572. DestinationFiles="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
  573. <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
  574. </Copy>
  575. </Target>
  576. <Target Name="GetTargetPath" Outputs="$(TargetPath)"/>
  577. <Target Name="GetCopyToOutputDirectoryItems"
  578. Outputs="@(AllItemsFullPathWithTargetPath)"
  579. DependsOnTargets="AssignTargetPaths;SplitProjectReferencesByExistent">
  580. <!-- FIXME: handle .vcproj
  581. FIXME: Private ProjectReferences are honored only in 3.5
  582. -->
  583. <MSBuild
  584. Projects="@(ProjectReferenceWithConfigurationExistent)"
  585. Targets="GetCopyToOutputDirectoryItems"
  586. Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and '%(ProjectReferenceWithConfigurationExistent.Private)' != 'false'">
  587. <Output TaskParameter="TargetOutputs" ItemName="AllChildProjectItemsWithTargetPath"/>
  588. </MSBuild>
  589. <!-- Process items from child project. The outputs need to have full path
  590. as they'll be used from other projects -->
  591. <CreateItem
  592. Include="@(AllChildProjectItemsWithTargetPath->'%(FullPath)')"
  593. Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
  594. <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
  595. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
  596. Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
  597. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
  598. Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
  599. </CreateItem>
  600. <!-- Process _this_ project's items -->
  601. <CreateItem
  602. Include="@(NoneWithTargetPath->'%(FullPath)')"
  603. Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(NoneWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
  604. <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
  605. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
  606. Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
  607. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
  608. Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
  609. </CreateItem>
  610. <CreateItem
  611. Include="@(ContentWithTargetPath->'%(FullPath)')"
  612. Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(ContentWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
  613. <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
  614. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
  615. Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
  616. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
  617. Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
  618. </CreateItem>
  619. <CreateItem
  620. Include="@(EmbeddedResourceWithTargetPath->'%(FullPath)')"
  621. Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
  622. <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
  623. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
  624. Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
  625. <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
  626. Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
  627. </CreateItem>
  628. </Target>
  629. <!-- Pre/Post BuildEvents -->
  630. <PropertyGroup>
  631. <PreBuildEventDependsOn />
  632. </PropertyGroup>
  633. <Target Name="PreBuildEvent"
  634. Condition="'$(PreBuildEvent)' != ''"
  635. DependsOnTargets="$(PreBuildEventDependsOn)">
  636. <Exec WorkingDirectory="$(OutDir)" Command="$(PreBuildEvent)" />
  637. </Target>
  638. <!-- PostBuildEvent depends on $(RunPostBuildEvent)
  639. Default: OnBuildSuccess
  640. OnBuildSuccess: Run after a successful build
  641. OnOutputUpdated: Run only if the output assembly got updates
  642. Always: Run always
  643. -->
  644. <PropertyGroup>
  645. <PostBuildEventDependsOn />
  646. </PropertyGroup>
  647. <!-- this gets invoked in two cases, from CoreBuildDependsOn, if the build completes
  648. successfully, OR from OnError in CoreBuild, if the build failed and $(RunPostBuildEvent)
  649. is 'Always' or 'OnOutputUpdated'. Invoke $(PostBuildEvent) if its either Empty (== OnBuildSuccess)
  650. or OnBuildSuccess or Always OR (OnOutputUpdated and output assembly got updated) -->
  651. <Target Name="PostBuildEvent"
  652. Condition="'$(PostBuildEvent)' != '' and
  653. ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or
  654. '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')"
  655. DependsOnTargets="$(PostBuildEventDependsOn)">
  656. <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
  657. </Target>
  658. <!-- Timestamp the output assemblies, required for PostBuildEvent -->
  659. <Target Name="_TimestampBeforeCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
  660. <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
  661. <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeBeforeCompile" />
  662. </CreateItem>
  663. </Target>
  664. <Target Name="_TimestampAfterCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
  665. <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
  666. <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeAfterCompile" />
  667. </CreateItem>
  668. </Target>
  669. <!-- Rebuild -->
  670. <PropertyGroup>
  671. <RebuildDependsOn>
  672. BeforeRebuild;
  673. Clean;
  674. $(MSBuildProjectDefaultTargets);
  675. AfterRebuild;
  676. </RebuildDependsOn>
  677. <RebuildDependsOn Condition="'$(MSBuildProjectDefaultTargets)' == 'Rebuild'">
  678. BeforeRebuild;
  679. Clean;
  680. Build;
  681. AfterRebuild;
  682. </RebuildDependsOn>
  683. </PropertyGroup>
  684. <Target Name="BeforeRebuild" />
  685. <Target Name="AfterRebuild" />
  686. <Target Name="Rebuild"
  687. DependsOnTargets="$(RebuildDependsOn)"
  688. Outputs="$(TargetPath)"/>
  689. <!-- Clean -->
  690. <Target Name="_RecordCleanFile"
  691. DependsOnTargets="_GetCompileOutputsForClean">
  692. <!-- add to list of previous writes for this platform/config -->
  693. <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
  694. <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
  695. </ReadLinesFromFile>
  696. <!-- CopyLocal files: In case all the projects build to common output
  697. directory, then other projects might depend on some of these
  698. CopyLocal files, so delete only the ones under *this* project
  699. directory -->
  700. <FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)">
  701. <Output TaskParameter="InPath" ItemName="FileWrites"/>
  702. </FindUnderPath>
  703. <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
  704. <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
  705. </RemoveDuplicates>
  706. <WriteLinesToFile
  707. File="$(IntermediateOutputPath)$(CleanFile)"
  708. Lines="@(CombinedFileWrites)"
  709. Overwrite="true"/>
  710. </Target>
  711. <PropertyGroup>
  712. <CleanDependsOn>
  713. BeforeClean;
  714. CleanReferencedProjects;
  715. CoreClean;
  716. AfterClean
  717. </CleanDependsOn>
  718. </PropertyGroup>
  719. <Target Name="_GetCompileOutputsForClean">
  720. <!-- assembly and debug file in the *intermediate output path* -->
  721. <CreateItem Include="@(IntermediateAssembly)" Condition="Exists('@(IntermediateAssembly)')">
  722. <Output TaskParameter="Include" ItemName="FileWrites"/>
  723. </CreateItem>
  724. <CreateItem Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
  725. Condition="Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')">
  726. <Output TaskParameter="Include" ItemName="FileWrites"/>
  727. </CreateItem>
  728. <CreateItem Include="$(IntermediateOutputPath)$(AssemblyName).pdb"
  729. Condition="Exists('$(IntermediateOutputPath)$(AssemblyName).pdb')">
  730. <Output TaskParameter="Include" ItemName="FileWrites"/>
  731. </CreateItem>
  732. </Target>
  733. <!-- Get the list of files written, for clean -->
  734. <Target Name="_GetCleanFileWrites"
  735. DependsOnTargets="_GetCompileOutputsForClean">
  736. <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
  737. <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
  738. </ReadLinesFromFile>
  739. </Target>
  740. <Target Name="CleanReferencedProjects"
  741. DependsOnTargets="AssignProjectConfiguration">
  742. <!-- If building from .sln.proj or from IDE, clean will get handled by them,
  743. else we are building a project directly, from the command line, so
  744. clean the referenced projects -->
  745. <MSBuild Projects="@(ProjectReferenceWithConfigurationExistent)"
  746. Targets="Clean"
  747. Condition=" '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' and '@(ProjectReferenceWithConfigurationExistent)' != ''" />
  748. </Target>
  749. <Target Name="Clean" DependsOnTargets="$(CleanDependsOn)"/>
  750. <!-- Override in project to run before/after clean tasks -->
  751. <Target Name="BeforeClean" />
  752. <Target Name="AfterClean" />
  753. <Target Name="CoreClean" DependsOnTargets="_GetCleanFileWrites">
  754. <Delete Files="@(PreviousFileWrites);@(FileWrites)" TreatErrorsAsWarnings="true"/>
  755. <!-- all previous files written for this platform/config have been deleted,
  756. we can safely remove the file list now -->
  757. <Delete Files="$(IntermediateOutputPath)$(CleanFile)" TreatErrorsAsWarnings="true" />
  758. </Target>
  759. <PropertyGroup>
  760. <ImplicitlyExpandDesignTimeFacades>true</ImplicitlyExpandDesignTimeFacades>
  761. <ResolveReferencesDependsOn>
  762. $(ResolveReferencesDependsOn);
  763. ImplicitlyExpandDesignTimeFacades
  764. </ResolveReferencesDependsOn>
  765. <ImplicitlyExpandDesignTimeFacadesDependsOn>
  766. $(ImplicitlyExpandDesignTimeFacadesDependsOn);
  767. GetReferenceAssemblyPaths
  768. </ImplicitlyExpandDesignTimeFacadesDependsOn>
  769. </PropertyGroup>
  770. <Target Name="ImplicitlyExpandDesignTimeFacades" Condition="'$(ImplicitlyExpandDesignTimeFacades)' == 'true'" DependsOnTargets="$(ImplicitlyExpandDesignTimeFacadesDependsOn)">
  771. <PropertyGroup>
  772. <!-- Does one of our dependencies reference a System.Runtime-based portable library? -->
  773. <_HasReferenceToSystemRuntime Condition="'$(DependsOnSystemRuntime)' == 'true' or '%(_ResolvedProjectReferencePaths.TargetPlatformIdentifier)' == 'Portable'">true</_HasReferenceToSystemRuntime>
  774. </PropertyGroup>
  775. <ItemGroup Condition="'$(_HasReferenceToSystemRuntime)' == 'true'">
  776. <!-- If the user has manually referenced these assemblies, remove them so we don't end up with duplicates -->
  777. <ReferencePath Remove="@(_DesignTimeFacadeAssemblies)"/>
  778. <ReferencePath Include="%(_DesignTimeFacadeAssemblies.Identity)">
  779. <WinMDFile>false</WinMDFile>
  780. <CopyLocal>false</CopyLocal>
  781. <ResolvedFrom>ImplicitlyExpandDesignTimeFacades</ResolvedFrom>
  782. </ReferencePath>
  783. <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)" Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandDesignTimeFacades'" />
  784. </ItemGroup>
  785. <Message Importance="Low" Text="Including @(ReferencePath)" Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandDesignTimeFacades'" />
  786. </Target>
  787. <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*"
  788. Condition="'$(ImportByWildcardAfterMicrosoftCommonTargets)' == 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
  789. </Project>