SharedFx.targets 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <Project>
  2. <Import Project="SharedFx.props" />
  3. <PropertyGroup>
  4. <SharedFxOutputPath>$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))runtime\</SharedFxOutputPath>
  5. </PropertyGroup>
  6. <Target Name="GetMetapackageArtifactInfo">
  7. <ItemGroup>
  8. <_MetapackageProject Include="$(RepositoryRoot)src\Packages\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj" />
  9. <_MetapackageProject Include="$(RepositoryRoot)src\Packages\Microsoft.AspNetCore.App\Microsoft.AspNetCore.App.csproj" />
  10. <_MetapackageProject Include="$(RepositoryRoot)src\Packages\Microsoft.AspNetCore.Analyzers\Microsoft.AspNetCore.Analyzers.csproj" />
  11. </ItemGroup>
  12. <MSBuild Projects="@(_MetapackageProject)"
  13. Targets="GetArtifactInfo"
  14. Properties="PackageOutputPath=$(BuildDir);BuildNumber=$(BuildNumber);DesignTimeBuild=true;IsFinalBuild=$(IsFinalBuild)">
  15. <Output TaskParameter="TargetOutputs" ItemName="ArtifactInfo" />
  16. </MSBuild>
  17. <ItemGroup>
  18. <!-- Cartesian products in MSBuild are fun :) -->
  19. <_SharedFrameworkSymbolsPackage Include="@(SharedFrameworkName)" Condition="'%(AllSharedFxRIDs.CrossgenSymbols)' != 'false' AND '%(AllSharedFxRIDs.Crossgen)' != 'false'">
  20. <Rid>%(AllSharedFxRIDs.Identity)</Rid>
  21. </_SharedFrameworkSymbolsPackage>
  22. <_SharedFrameworkSymbolsPackage Update="@(_SharedFrameworkSymbolsPackage)" PackageId="runtime.%(Rid).%(Identity)" />
  23. <ArtifactInfo Include="@(_SharedFrameworkSymbolsPackage->'$(BuildDir)%(PackageId).$(PackageVersion).symbols.nupkg')">
  24. <ArtifactType>NuGetSymbolsPackage</ArtifactType>
  25. <PackageId>%(_SharedFrameworkSymbolsPackage.PackageId)</PackageId>
  26. <Version>$(PackageVersion)</Version>
  27. <Category>shipoob</Category>
  28. </ArtifactInfo>
  29. </ItemGroup>
  30. </Target>
  31. <Target Name="_BuildMetapackage" DependsOnTargets="ResolveRepoInfo">
  32. <PropertyGroup>
  33. <MetapackageSource>$(_MetapackageSrcRoot)$(MetapackageName)\</MetapackageSource>
  34. <MetapackageWorkDirectory>$(_WorkRoot)pkg\$(MetapackageName)\</MetapackageWorkDirectory>
  35. <CommonProps />
  36. <CommonProps>$(CommonProps);Configuration=$(Configuration)</CommonProps>
  37. <CommonProps>$(CommonProps);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)</CommonProps>
  38. <CommonProps>$(CommonProps);DotNetBuildOffline=true</CommonProps>
  39. <CommonProps>$(CommonProps);AspNetUniverseBuildOffline=true</CommonProps>
  40. <CommonProps>$(CommonProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp22PackageVersion)</CommonProps>
  41. <CommonProps>$(CommonProps);AppMetapackageVersion=$(PackageVersion)</CommonProps>
  42. </PropertyGroup>
  43. <Error
  44. Text="Source directory $(MetapackageSource) for $(MetapackageName) does not exist."
  45. Condition="!Exists('$(MetapackageSource)')" />
  46. <ItemGroup>
  47. <MetapackageFiles Include="$(MetapackageSource)**\*" />
  48. </ItemGroup>
  49. <!-- Clear working directory -->
  50. <RemoveDir Directories="$(MetapackageWorkDirectory)" />
  51. <!-- Move to working dir -->
  52. <Copy SourceFiles="@(MetapackageFiles)" DestinationFolder="$(MetapackageWorkDirectory)%(RecursiveDir)" />
  53. <Copy SourceFiles="$(_MetapackageSrcRoot)Directory.Build.props" DestinationFolder="$(_WorkRoot)" />
  54. <!-- Add references to project -->
  55. <RepoTasks.AddMetapackageReferences
  56. ReferencePackagePath="$(MetapackageWorkDirectory)$(MetapackageName).csproj"
  57. MetapackageReferenceType="$(MetapackageReferenceType)"
  58. DependencyVersionRangeType="$(MetapackageDependencyVersionRangeType)"
  59. PackageArtifacts="@(_PackageArtifactSpec)"
  60. ExternalDependencies="@(ExternalDependency)" />
  61. <!-- Set _Target=Restore so the project will be re-evaluated to include Internal.AspNetCore.Sdk MSBuild properties on the next step. -->
  62. <MSBuild Projects="$(MetapackageWorkDirectory)$(MetapackageName).csproj" Targets="Restore" Properties="$(CommonProps);_Target=Restore" />
  63. <!-- Pack -->
  64. <MSBuild Projects="$(MetapackageWorkDirectory)$(MetapackageName).csproj" Targets="Pack" Properties="$(CommonProps);PackageOutputPath=$(BuildDir)" />
  65. </Target>
  66. <Target Name="BuildMetapackages">
  67. <ItemGroup>
  68. <_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
  69. <AdditionalProperties>
  70. MetapackageName=Microsoft.AspNetCore.App;
  71. MetapackageReferenceType=AppMetapackage;
  72. MetapackageDependencyVersionRangeType=MajorMinor
  73. </AdditionalProperties>
  74. </_MetapackageBuilderProject>
  75. <_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
  76. <AdditionalProperties>
  77. MetapackageName=Microsoft.AspNetCore.All;
  78. MetapackageReferenceType=AllMetapackage;
  79. MetapackageDependencyVersionRangeType=Minimum
  80. </AdditionalProperties>
  81. </_MetapackageBuilderProject>
  82. <_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
  83. <AdditionalProperties>
  84. MetapackageName=Microsoft.AspNetCore.Analyzers;
  85. MetapackageReferenceType=Analyzer;
  86. MetapackageDependencyVersionRangeType=Minimum
  87. </AdditionalProperties>
  88. </_MetapackageBuilderProject>
  89. </ItemGroup>
  90. <MSBuild
  91. Projects="@(_MetapackageBuilderProject)"
  92. Targets="_BuildMetapackage"
  93. BuildInParallel="false" />
  94. </Target>
  95. <Target Name="DefineSharedFxPrerequisites" DependsOnTargets="ResolveCommitHash">
  96. <PropertyGroup>
  97. <RIDIsAcceptable Condition="'%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)'">true</RIDIsAcceptable>
  98. <CrossGenSharedFx>false</CrossGenSharedFx>
  99. <CrossGenSharedFx Condition="'%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)' AND '%(AllSharedFxRIDs.Crossgen)' != 'false' ">true</CrossGenSharedFx>
  100. <CrossGenSharedFxSymbols>false</CrossGenSharedFxSymbols>
  101. <CrossGenSharedFxSymbols Condition="'$(CrossGenSharedFx)' != 'false' AND '%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)' AND '%(AllSharedFxRIDs.CrossgenSymbols)' != 'false' ">true</CrossGenSharedFxSymbols>
  102. </PropertyGroup>
  103. <Error Text="&quot;$(SharedFxRID)&quot; not acceptable as a SharedFxRID, please specify an acceptable value: {@(AllSharedFxRIDs)}." Condition="'$(RIDIsAcceptable)' != 'true'"/>
  104. <PropertyGroup>
  105. <AppSharedFxWorkDirectory>$(_WorkRoot)AppSharedFx\</AppSharedFxWorkDirectory>
  106. <AllSharedFxWorkDirectory>$(_WorkRoot)AllSharedFx\</AllSharedFxWorkDirectory>
  107. <SharedFxIntermediateOutputPath>$(_WorkRoot)Publish\</SharedFxIntermediateOutputPath>
  108. <SharedFxCrossGenDirectory>$(_WorkRoot)CrossGen\</SharedFxCrossGenDirectory>
  109. <SharedFxCrossGenSymbolsDirectory>$(_WorkRoot)CrossGenSymbols\</SharedFxCrossGenSymbolsDirectory>
  110. <SharedFxCrossGenToolDirectory>$(_WorkRoot)CrossGenTool\</SharedFxCrossGenToolDirectory>
  111. <SharedFxCrossGenRspDirectory>$(_WorkRoot)CrossGenRsp\</SharedFxCrossGenRspDirectory>
  112. <AppSharedFxPublishDirectory>$(SharedFxIntermediateOutputPath)shared\Microsoft.AspNetCore.App\$(PackageVersion)\</AppSharedFxPublishDirectory>
  113. <AllSharedFxPublishDirectory>$(SharedFxIntermediateOutputPath)shared\Microsoft.AspNetCore.All\$(PackageVersion)\</AllSharedFxPublishDirectory>
  114. <SharedFxRestoreRid>$(SharedFxRID)</SharedFxRestoreRid>
  115. <!-- 3B = semicolon in ASCII -->
  116. <PathSeparator Condition="'$(PathSeparator)' == ''">:</PathSeparator>
  117. <PathSeparator Condition="$(SharedFxRID.StartsWith('win'))">%3B</PathSeparator>
  118. <CommonSharedFxProps>Configuration=$(Configuration);RuntimeIdentifier=$(SharedFxRestoreRid)</CommonSharedFxProps>
  119. <CommonSharedFxProps>$(CommonSharedFxProps);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)</CommonSharedFxProps>
  120. <CommonSharedFxProps>$(CommonSharedFxProps);DotNetBuildOffline=true</CommonSharedFxProps>
  121. <CommonSharedFxProps>$(CommonSharedFxProps);AspNetUniverseBuildOffline=true</CommonSharedFxProps>
  122. </PropertyGroup>
  123. </Target>
  124. <Target Name="_PrepareForSharedFx" DependsOnTargets="DefineSharedFxPrerequisites">
  125. <PropertyGroup>
  126. <RestoreProps>$(CommonSharedFxProps)</RestoreProps>
  127. <RestoreProps>$(RestoreProps);SharedFxPackage=$(SharedFxPackage)</RestoreProps>
  128. <RestoreProps>$(RestoreProps);SharedFxPackageVersion=$(PackageVersion)</RestoreProps>
  129. <RestoreProps>$(RestoreProps);SharedFxBase=$(SharedFxBase)</RestoreProps>
  130. <RestoreProps>$(RestoreProps);SharedFxBaseVersion=$(SharedFxBaseVersion)</RestoreProps>
  131. </PropertyGroup>
  132. <!-- Copy to working dir -->
  133. <ItemGroup>
  134. <SharedFxFiles Include="$(_TemplatesDir)SharedFx\**\*" />
  135. </ItemGroup>
  136. <Copy SourceFiles="@(SharedFxFiles)" DestinationFolder="$(SharedFxWorkDirectory)\%(RecursiveDir)" />
  137. <!-- Set _Target=Restore so the project will be re-evaluated to include Internal.AspNetCore.Sdk MSBuild properties on the next step. -->
  138. <MSBuild Projects="$(SharedFxWorkDirectory)SharedFx.csproj"
  139. Targets="Restore"
  140. Properties="$(RestoreProps);_Target=Restore;RestoreForce=true" />
  141. </Target>
  142. <Target Name="PrepareForSharedFx" DependsOnTargets="DefineSharedFxPrerequisites;ResolveCommitHash">
  143. <PropertyGroup>
  144. <AppSharedFxProps>RepositoryCommit=$(RepositoryCommit);SharedFxWorkDirectory=$(AppSharedFxWorkDirectory)</AppSharedFxProps>
  145. <AppSharedFxProps>$(AppSharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp22PackageVersion)</AppSharedFxProps>
  146. <AppSharedFxProps>$(AppSharedFxProps);SharedFxPackage=Microsoft.AspNetCore.App</AppSharedFxProps>
  147. <AllSharedFxProps>RepositoryCommit=$(RepositoryCommit);SharedFxWorkDirectory=$(AllSharedFxWorkDirectory)</AllSharedFxProps>
  148. <AllSharedFxProps>$(AllSharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp22PackageVersion)</AllSharedFxProps>
  149. <AllSharedFxProps>$(AllSharedFxProps);SharedFxPackage=Microsoft.AspNetCore.All</AllSharedFxProps>
  150. <AllSharedFxProps>$(AllSharedFxProps);SharedFxDep=Microsoft.AspNetCore.App</AllSharedFxProps>
  151. <AllSharedFxProps>$(AllSharedFxProps);SharedFxDepVersion=$(PackageVersion)</AllSharedFxProps>
  152. </PropertyGroup>
  153. <!-- Clear working directory -->
  154. <!-- <RemoveDir Directories="$(_WorkRoot)" /> -->
  155. <Copy SourceFiles="$(_MetapackageSrcRoot)Directory.Build.props" DestinationFolder="$(_WorkRoot)" />
  156. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_PrepareForSharedFx" Properties="$(AppSharedFxProps)" />
  157. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_PrepareForSharedFx" Properties="$(AllSharedFxProps)" />
  158. </Target>
  159. <Target Name="_ResolveSharedFxFiles" DependsOnTargets="DefineSharedFxPrerequisites">
  160. <ItemGroup>
  161. <VersionLines Include="$(RepositoryCommit)" />
  162. <VersionLines Include="$(PackageVersion)" />
  163. </ItemGroup>
  164. <!-- Publish -->
  165. <MSBuild Projects="$(SharedFxWorkDirectory)SharedFx.csproj"
  166. Targets="Publish"
  167. Properties="$(CommonSharedFxProps);GenerateRuntimeConfigurationFiles=true;SelfContained=false;PublishDir=$(SharedFxPublishDirectory)" />
  168. <!-- Clean deps.json -->
  169. <RepoTasks.TrimDeps DepsFiles="$(SharedFxPublishDirectory)/SharedFx.deps.json" />
  170. <!-- Clean up artifacts that publish generates which we don't need -->
  171. <ItemGroup>
  172. <ToDelete Include="$(SharedFxPublishDirectory)\SharedFx" />
  173. <ToDelete Include="$(SharedFxPublishDirectory)\SharedFx.dll" />
  174. <ToDelete Include="$(SharedFxPublishDirectory)\SharedFx.pdb" />
  175. </ItemGroup>
  176. <Delete Files="@(ToDelete)" />
  177. <!-- Rename deps file -->
  178. <Move SourceFiles="$(SharedFxPublishDirectory)\SharedFx.deps.json"
  179. DestinationFiles="$(SharedFxPublishDirectory)\$(SharedFxPackage).deps.json" />
  180. <!-- Rename runtimeconfig.json file -->
  181. <Move SourceFiles="$(SharedFxPublishDirectory)\SharedFx.runtimeconfig.json"
  182. DestinationFiles="$(SharedFxPublishDirectory)\$(SharedFxPackage).runtimeconfig.json" />
  183. <!-- Generate Runtime Graph -->
  184. <PropertyGroup>
  185. <RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('Windows'))">win</RuntimeGraphGeneratorRuntime>
  186. <RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux</RuntimeGraphGeneratorRuntime>
  187. <RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx</RuntimeGraphGeneratorRuntime>
  188. </PropertyGroup>
  189. <ItemGroup>
  190. <SharedFxAssetsFile Include="$(SharedFxWorkDirectory)**\project.assets.json" />
  191. </ItemGroup>
  192. <ProcessSharedFrameworkDeps
  193. AssetsFilePath="@(SharedFxAssetsFile)"
  194. DepsFilePath="$(SharedFxPublishDirectory)\$(SharedFxPackage).deps.json"
  195. Runtime="$(RuntimeGraphGeneratorRuntime)" />
  196. <!-- Generate .version file -->
  197. <WriteLinesToFile
  198. File="$(SharedFxPublishDirectory)\.version"
  199. Lines="@(VersionLines)"
  200. Overwrite="true" />
  201. </Target>
  202. <Target Name="ResolveSharedFxFiles" DependsOnTargets="PrepareForSharedFx">
  203. <PropertyGroup>
  204. <AppSharedFxProps>SharedFxPackage=Microsoft.AspNetCore.App</AppSharedFxProps>
  205. <AppSharedFxProps>$(AppSharedFxProps);SharedFxWorkDirectory=$(AppSharedFxWorkDirectory)</AppSharedFxProps>
  206. <AppSharedFxProps>$(AppSharedFxProps);SharedFxPublishDirectory=$(AppSharedFxPublishDirectory)</AppSharedFxProps>
  207. <AllSharedFxProps>SharedFxPackage=Microsoft.AspNetCore.All</AllSharedFxProps>
  208. <AllSharedFxProps>$(AllSharedFxProps);SharedFxWorkDirectory=$(AllSharedFxWorkDirectory)</AllSharedFxProps>
  209. <AllSharedFxProps>$(AllSharedFxProps);SharedFxPublishDirectory=$(AllSharedFxPublishDirectory)</AllSharedFxProps>
  210. </PropertyGroup>
  211. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_ResolveSharedFxFiles" Properties="$(AppSharedFxProps)" />
  212. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_ResolveSharedFxFiles" Properties="$(AllSharedFxProps)" />
  213. <MakeDir Directories="$(SharedFxOutputPath)" />
  214. </Target>
  215. <Target Name="PrepareForCrossGen" DependsOnTargets="PrepareForSharedFx;ResolveSharedFxFiles">
  216. <PropertyGroup>
  217. <RuntimePackageName>Microsoft.NETCore.App</RuntimePackageName>
  218. <CrossGenTool>crossgen</CrossGenTool>
  219. <CrossGenTool Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(CrossGenTool).exe</CrossGenTool>
  220. </PropertyGroup>
  221. <!-- Determine runtime location (via .App shared framework) -->
  222. <MSBuild Projects="$(AppSharedFxWorkDirectory)SharedFx.csproj" Targets="GetPackageDefinitions" >
  223. <Output TaskParameter="TargetOutputs" ItemName="PackageDefinitions" />
  224. </MSBuild>
  225. <ItemGroup>
  226. <RuntimePackage Include="@(PackageDefinitions)" Condition="$([System.String]::new('%(PackageDefinitions.Name)').Contains('runtime')) AND $([System.String]::new('%(PackageDefinitions.Name)').Contains('$(RuntimePackageName)'))" />
  227. <RuntimePackageFiles Include="%(RuntimePackage.ResolvedPath)\runtimes\**\*" />
  228. <CrossGenToolFile Include="%(RuntimePackage.ResolvedPath)\**\$(CrossGenTool)" />
  229. </ItemGroup>
  230. <Error Text="Could not identify the runtime package for $(SharedFXRid)" Condition="@(RuntimePackage->Count()) == 0" />
  231. <!-- Create tool directory with crossgen executable and runtime assemblies -->
  232. <Copy SourceFiles="@(RuntimePackageFiles);@(CrossGenToolFile)" DestinationFolder="$(SharedFxCrossGenToolDirectory)"/>
  233. <ItemGroup>
  234. <ClrJitAssembly Include="$(SharedFxCrossGenToolDirectory)\**\$(LibPrefix)clrjit$(LibExtension)" />
  235. </ItemGroup>
  236. <Error Text="Expected to resolve a single runtime package but instead resolved @(RuntimePackage->Count()) with identities %(RuntimePackage.Identity)" Condition="'@(RuntimePackage->Count())' != 1" />
  237. <Error Text="Could not find crossgen in %(RuntimePackage.ResolvedPath)" Condition="@(CrossGenToolFile->Count()) == 0" />
  238. <Error Text="Expected to resolve a single clr jit assembly but instead resolved @(ClrJitAssembly->Count()) with identities %(ClrJitAssembly.Identity)" Condition="'@(ClrJitAssembly->Count())' != 1" />
  239. <!-- Gather details on published assemblies -->
  240. <MSBuild Projects="$(AppSharedFxWorkDirectory)SharedFx.csproj"
  241. Targets="GetPublishAssemblies"
  242. Properties="RuntimeIdentifier=$(SharedFxRestoreRid);SelfContained=false" >
  243. <Output TaskParameter="TargetOutputs" ItemName="AppPublishAssemblies" />
  244. </MSBuild>
  245. <MSBuild Projects="$(AllSharedFxWorkDirectory)SharedFx.csproj"
  246. Targets="GetPublishAssemblies"
  247. Properties="RuntimeIdentifier=$(SharedFxRestoreRid);SelfContained=false" >
  248. <Output TaskParameter="TargetOutputs" ItemName="AllPublishAssemblies" />
  249. </MSBuild>
  250. <ItemGroup>
  251. <IgnoredAssemblies Include="@(AppPublishAssemblies);@(AllPublishAssemblies)" Condition="'%(AssetType)' == 'native' OR '%(AssetType)' == 'resources'" />
  252. <_AppRuntimeAssemblies Include="@(AppPublishAssemblies)" Condition="'%(AssetType)' == 'runtime'">
  253. <SymbolsPackageFilename>%(PackageName).%(PackageVersion).symbols.nupkg</SymbolsPackageFilename>
  254. <PortablePDB>%(RootDir)%(Directory)%(Filename).pdb</PortablePDB>
  255. </_AppRuntimeAssemblies>
  256. <_AllRuntimeAssemblies Include="@(AllPublishAssemblies)" Exclude="@(_AppRuntimeAssemblies)" Condition="'%(AssetType)' == 'runtime'">
  257. <SymbolsPackageFilename>%(PackageName).%(PackageVersion).symbols.nupkg</SymbolsPackageFilename>
  258. <PortablePDB>%(RootDir)%(Directory)%(Filename).pdb</PortablePDB>
  259. </_AllRuntimeAssemblies>
  260. <OtherAssemblies Include="@(AppPublishAssemblies);@(AllPublishAssemblies)" Exclude="@(IgnoredAssemblies);@(_AppRuntimeAssemblies);@(_AllRuntimeAssemblies)" />
  261. <_AssembliesToCrossgen Include="$(SharedFxIntermediateOutputPath)**\*.dll" />
  262. </ItemGroup>
  263. <RepoTasks.ResolveSymbolsRecursivePath Symbols="@(_AppRuntimeAssemblies)">
  264. <Output TaskParameter="Symbols" ItemName="AppRuntimeAssemblies" />
  265. </RepoTasks.ResolveSymbolsRecursivePath>
  266. <RepoTasks.ResolveSymbolsRecursivePath Symbols="@(_AllRuntimeAssemblies)">
  267. <Output TaskParameter="Symbols" ItemName="AllRuntimeAssemblies" />
  268. </RepoTasks.ResolveSymbolsRecursivePath>
  269. <Error Text="Unaccounted shared framework assemblies found: @(OtherAssemblies). Assemblies must be included as runtime assemblies or marked as ignored." Condition="'@(OtherAssemblies)' != ''" />
  270. <!-- Compute the intersection of crossgen candidates and native/resources assemblies as the set of assemblies to skip crossgen -->
  271. <CreateItem Include="@(_AssembliesToCrossgen)" Condition="'%(Filename)' != ''and '@(IgnoredAssemblies)' != ''">
  272. <Output TaskParameter="Include" ItemName="AssembliesToRemove"/>
  273. </CreateItem>
  274. <!-- Resolve list of assemblies to crossgen -->
  275. <ItemGroup>
  276. <AssembliesToCrossgen Include="@(_AssembliesToCrossgen)">
  277. <Source>%(FullPath)</Source>
  278. <Rsp>$(SharedFxCrossGenRspDirectory)%(RecursiveDir)%(Filename).rsp</Rsp>
  279. <SymbolsRsp>$(SharedFxCrossGenRspDirectory)%(RecursiveDir)%(Filename).symbols.rsp</SymbolsRsp>
  280. <Destination>$(SharedFxCrossGenDirectory)%(RecursiveDir)%(Filename)%(Extension)</Destination>
  281. <Symbols>$(SharedFxCrossGenDirectory)%(RecursiveDir)</Symbols>
  282. </AssembliesToCrossgen>
  283. <AssembliesToCrossgen Remove="@(AssembliesToRemove)" />
  284. </ItemGroup>
  285. <!-- Compute the intersection of runtime assemblies and assemblies to crossgen to resolve the set of portablePDBs to publish -->
  286. <CreateItem Include="@(AppRuntimeAssemblies)" Condition="'%(Filename)' != ''and '@(AssembliesToCrossgen)' != ''">
  287. <Output TaskParameter="Include" ItemName="AppPortablePDBsToPublish"/>
  288. </CreateItem>
  289. <CreateItem Include="@(AllRuntimeAssemblies)" Condition="'%(Filename)' != ''and '@(AssembliesToCrossgen)' != ''">
  290. <Output TaskParameter="Include" ItemName="AllPortablePDBsToPublish"/>
  291. </CreateItem>
  292. </Target>
  293. <Target Name="CrossGenAssemblies"
  294. DependsOnTargets="PrepareForCrossGen"
  295. Inputs="@(AssembliesToCrossgen)"
  296. Outputs="%(AssembliesToCrossgen.Destination)">
  297. <ItemGroup>
  298. <CrossGenArgs Include="-nologo" />
  299. <CrossGenArgs Include="-readytorun" />
  300. <CrossGenArgs Include="-in %(AssembliesToCrossgen.Source)" />
  301. <CrossGenArgs Include="-out %(AssembliesToCrossgen.Destination)" />
  302. <CrossGenArgs Include="-platform_assemblies_paths $(SharedFxCrossGenToolDirectory)$(PathSeparator)$(AppSharedFxPublishDirectory)$(PathSeparator)$(AllSharedFxPublishDirectory)" />
  303. <CrossGenArgs Include="-JITPath %(ClrJitAssembly.FullPath)" />
  304. </ItemGroup>
  305. <MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Rsp)'))" />
  306. <MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Destination)'))" />
  307. <WriteLinesToFile File="%(AssembliesToCrossgen.Rsp)" Lines="@(CrossGenArgs)" Overwrite="true" />
  308. <Copy Condition="'$(CrossGenSharedFx)' == 'false'"
  309. SourceFiles="%(AssembliesToCrossgen.Source)"
  310. DestinationFiles="%(AssembliesToCrossgen.Destination)" />
  311. <Exec Condition="'$(CrossGenSharedFx)' != 'false'"
  312. Command="$(SharedFxCrossGenToolDirectory)$(CrossGenTool) @%(AssembliesToCrossgen.Rsp)"
  313. EnvironmentVariables="COMPlus_PartialNGen=0" />
  314. </Target>
  315. <Target Name="CrossGenSymbols"
  316. Condition=" '$(CrossGenSharedFxSymbols)' != 'false' "
  317. DependsOnTargets="CrossGenAssemblies"
  318. Inputs="@(AssembliesToCrossgen)"
  319. Outputs="%(AssembliesToCrossgen.SymbolsRsp)">
  320. <PropertyGroup>
  321. <CrossGenSymbolsType>CreatePerfMap</CrossGenSymbolsType>
  322. <CrossGenSymbolsType Condition="'$(OS)' == 'Windows_NT'">CreatePDB</CrossGenSymbolsType>
  323. </PropertyGroup>
  324. <ItemGroup>
  325. <CrossGenSymbolsArgs Include="-nologo" />
  326. <CrossGenSymbolsArgs Include="-readytorun" />
  327. <CrossGenSymbolsArgs Include="-platform_assemblies_paths $(SharedFxCrossGenToolDirectory)$(PathSeparator)$(AppSharedFxPublishDirectory)$(PathSeparator)$(AllSharedFxPublishDirectory)" />
  328. <CrossGenSymbolsArgs Include="-$(CrossGenSymbolsType)" />
  329. <CrossGenSymbolsArgs Include="%(AssembliesToCrossgen.Symbols)" />
  330. <CrossGenSymbolsArgs Include="%(AssembliesToCrossgen.Destination)" />
  331. </ItemGroup>
  332. <MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Symbols)'))" />
  333. <WriteLinesToFile File="%(AssembliesToCrossgen.SymbolsRsp)" Lines="@(CrossGenSymbolsArgs)" Overwrite="true" />
  334. <Exec Command="$(SharedFxCrossGenToolDirectory)$(CrossGenTool) @%(AssembliesToCrossgen.SymbolsRsp)" EnvironmentVariables="COMPlus_PartialNGen=0" />
  335. </Target>
  336. <Target Name="_BuildSharedFxSymbols">
  337. <PropertyGroup>
  338. <SymbolsPackageId>runtime.$(SharedFxRID).$(SymbolsNuspecIdSuffix)</SymbolsPackageId>
  339. </PropertyGroup>
  340. <ItemGroup>
  341. <_SymbolFiles Include="$(SymbolsWorkDir)**\*.pdb;$(SymbolsWorkDir)**\*.map;$(SymbolsWorkDir)**\*.dll" />
  342. <SymbolFiles Include="@(_SymbolFiles)">
  343. <PackagePath>%(RecursiveDir)%(Filename)%(Extension)</PackagePath>
  344. </SymbolFiles>
  345. </ItemGroup>
  346. <!-- Create Layout -->
  347. <Copy
  348. SourceFiles="$(_TemplatesDir)SharedFxSymbols\SharedFrameworkSymbols.nuspec"
  349. DestinationFiles="$(SymbolsWorkDir)$(SymbolsPackageId).nuspec"
  350. OverwriteReadOnlyFiles="True" />
  351. <!-- Produce symbols nupkg -->
  352. <PackNuspec NuspecPath="$(SymbolsWorkDir)$(SymbolsPackageId).nuspec"
  353. OutputPath="$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))symbols\$(SymbolsPackageId).$(PackageVersion).symbols.nupkg"
  354. Properties="version=$(PackageVersion);id=$(SymbolsPackageId);description=$(Description);Configuration=$(Configuration)"
  355. Overwrite="true"
  356. PackageFiles="@(SymbolFiles)"
  357. BasePath="$(SymbolsWorkDir)" />
  358. </Target>
  359. <Target Name="PackSharedFx" DependsOnTargets="DefineSharedFxPrerequisites" >
  360. <PropertyGroup>
  361. <AppSharedFxCrossgenDirectory>$(SharedFxCrossGenDirectory)shared\Microsoft.AspNetCore.App\$(PackageVersion)\</AppSharedFxCrossgenDirectory>
  362. <AllSharedFxCrossgenDirectory>$(SharedFxCrossGenDirectory)shared\Microsoft.AspNetCore.All\$(PackageVersion)\</AllSharedFxCrossgenDirectory>
  363. <AppSharedFxSymbolsDirectory>$(_WorkRoot)Symbols\Microsoft.AspNetCore.App\</AppSharedFxSymbolsDirectory>
  364. <AllSharedFxSymbolsDirectory>$(_WorkRoot)Symbols\Microsoft.AspNetCore.All\</AllSharedFxSymbolsDirectory>
  365. </PropertyGroup>
  366. <ItemGroup>
  367. <AppCrossGenOutput Include="$(AppSharedFxCrossgenDirectory)**\*.dll" />
  368. <AllCrossGenOutput Include="$(AllSharedFxCrossgenDirectory)**\*.dll" />
  369. <AppCrossGenSymbols Include="$(AppSharedFxCrossgenDirectory)**\*" Exclude="@(AppCrossGenOutput)" />
  370. <AllCrossGenSymbols Include="$(AllSharedFxCrossgenDirectory)**\*" Exclude="@(AllCrossGenOutput)" />
  371. </ItemGroup>
  372. <!-- Extract symbols package and copy over PDBs -->
  373. <UnzipArchive
  374. File="$(_SymbolsSourceDir)%(AppPortablePDBsToPublish.SymbolsPackageFilename)"
  375. Destination="$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)"
  376. Condition="Exists('$(_SymbolsSourceDir)%(AppPortablePDBsToPublish.SymbolsPackageFilename)')" />
  377. <UnzipArchive
  378. File="$(_SymbolsSourceDir)%(AllPortablePDBsToPublish.SymbolsPackageFilename)"
  379. Destination="$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)"
  380. Condition="Exists('$(_SymbolsSourceDir)%(AllPortablePDBsToPublish.SymbolsPackageFilename)')" />
  381. <Copy
  382. SourceFiles="$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)%(AppPortablePDBsToPublish.SymbolsRecursivePath)"
  383. DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  384. OverwriteReadOnlyFiles="True"
  385. Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)\%(AppPortablePDBsToPublish.SymbolsRecursivePath)')" />
  386. <Copy
  387. SourceFiles="$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)%(AllPortablePDBsToPublish.SymbolsRecursivePath)"
  388. DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  389. OverwriteReadOnlyFiles="True"
  390. Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)\%(AllPortablePDBsToPublish.SymbolsRecursivePath)')" />
  391. <!-- Copy over DLLs and PDBs -->
  392. <Copy
  393. SourceFiles="%(AppPortablePDBsToPublish.PortablePDB)"
  394. DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  395. OverwriteReadOnlyFiles="True"
  396. Condition="Exists('%(AppPortablePDBsToPublish.PortablePDB)')" />
  397. <Copy
  398. SourceFiles="%(AllPortablePDBsToPublish.PortablePDB)"
  399. DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  400. OverwriteReadOnlyFiles="True"
  401. Condition="Exists('%(AllPortablePDBsToPublish.PortablePDB)')" />
  402. <Copy
  403. SourceFiles="@(AppCrossGenSymbols)"
  404. DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  405. OverwriteReadOnlyFiles="True" />
  406. <Copy
  407. SourceFiles="@(AllCrossGenSymbols)"
  408. DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  409. OverwriteReadOnlyFiles="True" />
  410. <Copy
  411. SourceFiles="$(AppSharedFxCrossgenDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
  412. DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  413. OverwriteReadOnlyFiles="True" />
  414. <Copy
  415. SourceFiles="$(AllSharedFxCrossgenDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
  416. DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
  417. OverwriteReadOnlyFiles="True" />
  418. <!-- Create symbols nupkg -->
  419. <PropertyGroup>
  420. <AppSymbolsArguments>SymbolsWorkDir=$(AppSharedFxSymbolsDirectory)</AppSymbolsArguments>
  421. <AppSymbolsArguments>$(AppSymbolsArguments);SymbolsNuspecIdSuffix=Microsoft.AspNetCore.App</AppSymbolsArguments>
  422. <AppSymbolsArguments>$(AppSymbolsArguments);Description=Symbol packages for Microsoft.AspNetCore.App shared framework</AppSymbolsArguments>
  423. <AllSymbolsArguments>SymbolsWorkDir=$(AllSharedFxSymbolsDirectory)</AllSymbolsArguments>
  424. <AllSymbolsArguments>$(AllSymbolsArguments);SymbolsNuspecIdSuffix=Microsoft.AspNetCore.All</AllSymbolsArguments>
  425. <AllSymbolsArguments>$(AllSymbolsArguments);Description=Symbol packages for Microsoft.AspNetCore.All shared framework</AllSymbolsArguments>
  426. </PropertyGroup>
  427. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_BuildSharedFxSymbols" Properties="$(AppSymbolsArguments)" />
  428. <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_BuildSharedFxSymbols" Properties="$(AllSymbolsArguments)" />
  429. <!-- Replace assemblies with crossgen output -->
  430. <Copy
  431. SourceFiles="$(AppSharedFxCrossgenDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
  432. DestinationFiles="$(AppSharedFxPublishDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
  433. OverwriteReadOnlyFiles="True" />
  434. <Copy
  435. SourceFiles="$(AllSharedFxCrossgenDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
  436. DestinationFiles="$(AllSharedFxPublishDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
  437. OverwriteReadOnlyFiles="True" />
  438. <ItemGroup>
  439. <OutputZipFiles Include="$(SharedFxIntermediateOutputPath)**\*" />
  440. </ItemGroup>
  441. <!-- Create internal archive file -->
  442. <Exec Condition="'$(ArchiveExtension)' == '.tar.gz'"
  443. Command="tar -czf $(SharedFxOutputPath)$(SharedFxIntermediateArchiveBaseName)-$(PackageVersion)-$(SharedFxRID)$(ArchiveExtension) -C $(SharedFxIntermediateOutputPath) ." />
  444. <ZipArchive Condition="'$(ArchiveExtension)' == '.zip'"
  445. File="$(SharedFxOutputPath)$(SharedFxIntermediateArchiveBaseName)-$(PackageVersion)-$(SharedFxRID).zip"
  446. SourceFiles="@(OutputZipFiles)"
  447. WorkingDirectory="$(SharedFxIntermediateOutputPath)"
  448. Overwrite="true"/>
  449. </Target>
  450. <Target Name="BuildSharedFx" DependsOnTargets="GeneratePropsFiles;ResolveSharedFxFiles;CrossGenAssemblies;CrossGenSymbols;PackSharedFx;TestSharedFx"/>
  451. <Target Name="TestSharedFx" DependsOnTargets="GeneratePropsFiles;DefineSharedFxPrerequisites;ResolveCommitHash;InstallDotNet">
  452. <PropertyGroup>
  453. <UnitTestFxProject>$(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj</UnitTestFxProject>
  454. <!-- The file path to the log file, from within the container -->
  455. <UnitTestFxTrxLogFile>$(LogOutputDir)SharedFx-UnitTests-$(Version).trx</UnitTestFxTrxLogFile>
  456. <!-- The trx file path from the perspective of the TeamCity agent -->
  457. <UnitTestFxTrxPhysicalFilePath>$(UnitTestFxTrxLogFile)</UnitTestFxTrxPhysicalFilePath>
  458. <UnitTestFxTrxPhysicalFilePath Condition="'$(HostMachineRepositoryRoot)' != ''">$(HostMachineRepositoryRoot)/artifacts/logs/SharedFx-UnitTests.trx</UnitTestFxTrxPhysicalFilePath>
  459. <UnitTestFxTestProps>
  460. DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
  461. DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);
  462. SharedFxOutputPath=$(SharedFxIntermediateOutputPath);
  463. RepositoryCommit=$(RepositoryCommit);
  464. VSTestLogger=$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
  465. SharedFxRuntimeIdentifier=$(SharedFXRid)
  466. </UnitTestFxTestProps>
  467. </PropertyGroup>
  468. <MSBuild Projects="$(UnitTestFxProject)" Targets="Restore" Properties="_Dummy=restore;$(UnitTestFxTestProps)" />
  469. <MSBuild Projects="$(UnitTestFxProject)" Targets="Build" Properties="$(UnitTestFxTestProps)">
  470. <Output TaskParameter="TargetOutputs" ItemName="SharedFxTestAssembly" />
  471. </MSBuild>
  472. <RunDotNet Arguments="vstest;
  473. --Framework:%(TargetFrameworkIdentifier),Version=v%(TargetFrameworkVersion);
  474. --Logger:$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
  475. %(SharedFxTestAssembly.Identity);
  476. --;RunConfiguration.NoAutoReporters=true" IgnoreExitCode="true">
  477. <Output TaskParameter="ExitCode" PropertyName="VsTestExitCode" />
  478. </RunDotNet>
  479. <Message Text="##teamcity[importData type='vstest' path='$(UnitTestFxTrxPhysicalFilePath)']"
  480. Importance="High"
  481. Condition="'$(TEAMCITY_VERSION)' != '' AND Exists('$(UnitTestFxTrxLogFile)')" />
  482. <Error Text="SharedFx.UnitTests failed with exit code '$(VsTestExitCode)'." Condition=" $(VsTestExitCode) != 0 " />
  483. </Target>
  484. </Project>