aspnetcore/build/SharedFx.targets

575 строки
33 KiB
XML

<Project>
<Import Project="SharedFx.props" />
<PropertyGroup>
<SharedFxOutputPath>$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))runtime\</SharedFxOutputPath>
</PropertyGroup>
<Target Name="GetMetapackageArtifactInfo">
<ItemGroup>
<_MetapackageProject Include="$(RepositoryRoot)src\Packages\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj" />
<_MetapackageProject Include="$(RepositoryRoot)src\Packages\Microsoft.AspNetCore.App\Microsoft.AspNetCore.App.csproj" />
</ItemGroup>
<MSBuild Projects="@(_MetapackageProject)"
Targets="GetArtifactInfo"
Properties="PackageOutputPath=$(BuildDir);BuildNumber=$(BuildNumber);DesignTimeBuild=true;IsFinalBuild=$(IsFinalBuild)">
<Output TaskParameter="TargetOutputs" ItemName="ArtifactInfo" />
</MSBuild>
<ItemGroup>
<!-- Cartesian products in MSBuild are fun :) -->
<_SharedFrameworkSymbolsPackage Include="@(SharedFrameworkName)" Condition="'%(AllSharedFxRIDs.CrossgenSymbols)' != 'false' AND '%(AllSharedFxRIDs.Crossgen)' != 'false'">
<Rid>%(AllSharedFxRIDs.Identity)</Rid>
</_SharedFrameworkSymbolsPackage>
<_SharedFrameworkSymbolsPackage Update="@(_SharedFrameworkSymbolsPackage)" PackageId="runtime.%(Rid).%(Identity)" />
<ArtifactInfo Include="@(_SharedFrameworkSymbolsPackage->'$(BuildDir)%(PackageId).$(PackageVersion).symbols.nupkg')">
<ArtifactType>NuGetSymbolsPackage</ArtifactType>
<PackageId>%(_SharedFrameworkSymbolsPackage.PackageId)</PackageId>
<Version>$(PackageVersion)</Version>
<Category>shipoob</Category>
</ArtifactInfo>
</ItemGroup>
</Target>
<Target Name="_BuildMetapackage" DependsOnTargets="ResolveSharedSourcesPackageInfo;GetProjectArtifactInfo;ResolveRepoInfo">
<PropertyGroup>
<MetapackageSource>$(_MetapackageSrcRoot)$(MetapackageName)\</MetapackageSource>
<MetapackageWorkDirectory>$(_WorkRoot)pkg\$(MetapackageName)\</MetapackageWorkDirectory>
<CommonProps />
<CommonProps>$(CommonProps);Configuration=$(Configuration)</CommonProps>
<CommonProps>$(CommonProps);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)</CommonProps>
<CommonProps>$(CommonProps);DotNetBuildOffline=true</CommonProps>
<CommonProps>$(CommonProps);AspNetUniverseBuildOffline=true</CommonProps>
<CommonProps>$(CommonProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion)</CommonProps>
<CommonProps>$(CommonProps);AppMetapackageVersion=$(PackageVersion)</CommonProps>
<CommonProps>$(CommonProps);BuildNumber=$(BuildNumber)</CommonProps>
</PropertyGroup>
<Error
Text="Source directory $(MetapackageSource) for $(MetapackageName) does not exist."
Condition="!Exists('$(MetapackageSource)')" />
<ItemGroup>
<MetapackageFiles Include="$(MetapackageSource)**\*" />
</ItemGroup>
<!-- Clear working directory -->
<RemoveDir Directories="$(MetapackageWorkDirectory)" />
<!-- Move to working dir -->
<Copy SourceFiles="@(MetapackageFiles)" DestinationFolder="$(MetapackageWorkDirectory)%(RecursiveDir)" />
<Copy SourceFiles="$(_MetapackageSrcRoot)Directory.Build.props" DestinationFolder="$(_WorkRoot)" />
<!-- Add references to project -->
<RepoTasks.AddMetapackageReferences
ReferencePackagePath="$(MetapackageWorkDirectory)$(MetapackageName).csproj"
MetapackageReferenceType="$(MetapackageReferenceType)"
DependencyVersionRangeType="$(MetapackageDependencyVersionRangeType)"
PackageArtifacts="@(_PackageArtifactSpec)"
ExternalDependencies="@(ExternalDependency)" />
<!-- Set _Target=Restore so the project will be re-evaluated to include Internal.AspNetCore.Sdk MSBuild properties on the next step. -->
<MSBuild Projects="$(MetapackageWorkDirectory)$(MetapackageName).csproj" Targets="Restore" Properties="$(CommonProps);_Target=Restore" />
<!-- Pack -->
<MSBuild Projects="$(MetapackageWorkDirectory)$(MetapackageName).csproj" Targets="Pack" Properties="$(CommonProps);PackageOutputPath=$(BuildDir)" />
</Target>
<Target Name="BuildMetapackages">
<ItemGroup>
<_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>
MetapackageName=Microsoft.AspNetCore.App;
MetapackageReferenceType=AppMetapackage;
MetapackageDependencyVersionRangeType=MajorMinor
</AdditionalProperties>
</_MetapackageBuilderProject>
<_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>
MetapackageName=Microsoft.AspNetCore.All;
MetapackageReferenceType=AllMetapackage;
MetapackageDependencyVersionRangeType=Minimum
</AdditionalProperties>
</_MetapackageBuilderProject>
</ItemGroup>
<MSBuild
Projects="@(_MetapackageBuilderProject)"
Targets="_BuildMetapackage"
BuildInParallel="false" />
</Target>
<Target Name="BuildSiteExtension" DependsOnTargets="BuildMetapackages" Condition="'$(BuildSiteExtension)' == 'true'" >
<PropertyGroup>
<AzureIntegrationProjProperties>
AspNetUniverseBuildOffline=true;
DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);
BuildNumber=$(BuildNumber);
Configuration=$(Configuration);
IsFinalBuild=$(IsFinalBuild);
</AzureIntegrationProjProperties>
</PropertyGroup>
<!-- Pack logging site extension -->
<MSBuild Projects="$(RepositoryRoot)\src\SiteExtensions\LoggingBranch\LoggingBranch.csproj" Targets="Restore;Pack" Properties="$(AzureIntegrationProjProperties);PackageOutputPath=$(BuildDir)" />
</Target>
<Target Name="GetSiteExtensionArtifactInfo" Condition="'$(BuildSiteExtension)' == 'true'" >
<MSBuild Projects="$(RepositoryRoot)\src\SiteExtensions\LoggingBranch\LoggingBranch.csproj" Targets="GetArtifactInfo" Properties="PackageOutputPath=$(BuildDir);BuildNumber=$(BuildNumber);DesignTimeBuild=true;IsFinalBuild=$(IsFinalBuild)">
<Output TaskParameter="TargetOutputs" ItemName="ArtifactInfo" />
</MSBuild>
</Target>
<Target Name="DefineSharedFxPrerequisites" DependsOnTargets="ResolveCommitHash">
<PropertyGroup>
<RIDIsAcceptable Condition="'%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)'">true</RIDIsAcceptable>
<CrossGenSharedFx>false</CrossGenSharedFx>
<CrossGenSharedFx Condition="'%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)' AND '%(AllSharedFxRIDs.Crossgen)' != 'false' ">true</CrossGenSharedFx>
<CrossGenSharedFxSymbols>false</CrossGenSharedFxSymbols>
<CrossGenSharedFxSymbols Condition="'$(CrossGenSharedFx)' != 'false' AND '%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)' AND '%(AllSharedFxRIDs.CrossgenSymbols)' != 'false' ">true</CrossGenSharedFxSymbols>
</PropertyGroup>
<Error Text="&quot;$(SharedFxRID)&quot; not acceptable as a SharedFxRID, please specify an acceptable value: {@(AllSharedFxRIDs)}." Condition="'$(RIDIsAcceptable)' != 'true'"/>
<PropertyGroup>
<AppSharedFxWorkDirectory>$(_WorkRoot)AppSharedFx\</AppSharedFxWorkDirectory>
<AllSharedFxWorkDirectory>$(_WorkRoot)AllSharedFx\</AllSharedFxWorkDirectory>
<SharedFxIntermediateOutputPath>$(_WorkRoot)Publish\</SharedFxIntermediateOutputPath>
<SharedFxCrossGenDirectory>$(_WorkRoot)CrossGen\</SharedFxCrossGenDirectory>
<SharedFxCrossGenSymbolsDirectory>$(_WorkRoot)CrossGenSymbols\</SharedFxCrossGenSymbolsDirectory>
<SharedFxCrossGenToolDirectory>$(_WorkRoot)CrossGenTool\</SharedFxCrossGenToolDirectory>
<SharedFxCrossGenRspDirectory>$(_WorkRoot)CrossGenRsp\</SharedFxCrossGenRspDirectory>
<AppSharedFxPublishDirectory>$(SharedFxIntermediateOutputPath)shared\Microsoft.AspNetCore.App\$(PackageVersion)\</AppSharedFxPublishDirectory>
<AllSharedFxPublishDirectory>$(SharedFxIntermediateOutputPath)shared\Microsoft.AspNetCore.All\$(PackageVersion)\</AllSharedFxPublishDirectory>
<SharedFxRestoreRid>$(SharedFxRID)</SharedFxRestoreRid>
<!-- 3B = semicolon in ASCII -->
<PathSeparator Condition="'$(PathSeparator)' == ''">:</PathSeparator>
<PathSeparator Condition="$(SharedFxRID.StartsWith('win'))">%3B</PathSeparator>
<CommonSharedFxProps>Configuration=$(Configuration);RuntimeIdentifier=$(SharedFxRestoreRid)</CommonSharedFxProps>
<CommonSharedFxProps>$(CommonSharedFxProps);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)</CommonSharedFxProps>
<CommonSharedFxProps>$(CommonSharedFxProps);DotNetBuildOffline=true</CommonSharedFxProps>
<CommonSharedFxProps>$(CommonSharedFxProps);AspNetUniverseBuildOffline=true</CommonSharedFxProps>
</PropertyGroup>
</Target>
<Target Name="_PrepareForSharedFx" DependsOnTargets="DefineSharedFxPrerequisites">
<PropertyGroup>
<RestoreProps>$(CommonSharedFxProps)</RestoreProps>
<RestoreProps>$(RestoreProps);SharedFxPackage=$(SharedFxPackage)</RestoreProps>
<RestoreProps>$(RestoreProps);SharedFxPackageVersion=$(PackageVersion)</RestoreProps>
<RestoreProps>$(RestoreProps);SharedFxBase=$(SharedFxBase)</RestoreProps>
<RestoreProps>$(RestoreProps);SharedFxBaseVersion=$(SharedFxBaseVersion)</RestoreProps>
</PropertyGroup>
<!-- Copy to working dir -->
<ItemGroup>
<SharedFxFiles Include="$(_TemplatesDir)SharedFx\**\*" />
</ItemGroup>
<Copy SourceFiles="@(SharedFxFiles)" DestinationFolder="$(SharedFxWorkDirectory)\%(RecursiveDir)" />
<!-- Set _Target=Restore so the project will be re-evaluated to include Internal.AspNetCore.Sdk MSBuild properties on the next step. -->
<MSBuild Projects="$(SharedFxWorkDirectory)SharedFx.csproj"
Targets="Restore"
Properties="$(RestoreProps);_Target=Restore;RestoreForce=true" />
</Target>
<Target Name="PrepareForSharedFx" DependsOnTargets="DefineSharedFxPrerequisites;ResolveCommitHash">
<PropertyGroup>
<AppSharedFxProps>RepositoryCommit=$(RepositoryCommit);SharedFxWorkDirectory=$(AppSharedFxWorkDirectory)</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion)</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);SharedFxPackage=Microsoft.AspNetCore.App</AppSharedFxProps>
<AllSharedFxProps>RepositoryCommit=$(RepositoryCommit);SharedFxWorkDirectory=$(AllSharedFxWorkDirectory)</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion)</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);SharedFxPackage=Microsoft.AspNetCore.All</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);SharedFxDep=Microsoft.AspNetCore.App</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);SharedFxDepVersion=$(PackageVersion)</AllSharedFxProps>
</PropertyGroup>
<!-- Clear working directory -->
<!-- <RemoveDir Directories="$(_WorkRoot)" /> -->
<Copy SourceFiles="$(_MetapackageSrcRoot)Directory.Build.props" DestinationFolder="$(_WorkRoot)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_PrepareForSharedFx" Properties="$(AppSharedFxProps)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_PrepareForSharedFx" Properties="$(AllSharedFxProps)" />
</Target>
<Target Name="_ResolveSharedFxFiles" DependsOnTargets="DefineSharedFxPrerequisites">
<ItemGroup>
<VersionLines Include="$(RepositoryCommit)" />
<VersionLines Include="$(PackageVersion)" />
</ItemGroup>
<!-- Publish -->
<MSBuild Projects="$(SharedFxWorkDirectory)SharedFx.csproj"
Targets="Publish"
Properties="$(CommonSharedFxProps);GenerateRuntimeConfigurationFiles=true;SelfContained=false;PublishDir=$(SharedFxPublishDirectory)" />
<!-- Clean deps.json -->
<RepoTasks.TrimDeps DepsFiles="$(SharedFxPublishDirectory)/SharedFx.deps.json" />
<!-- Clean up artifacts that publish generates which we don't need -->
<ItemGroup>
<ToDelete Include="$(SharedFxPublishDirectory)\SharedFx" />
<ToDelete Include="$(SharedFxPublishDirectory)\SharedFx.dll" />
<ToDelete Include="$(SharedFxPublishDirectory)\SharedFx.pdb" />
</ItemGroup>
<Delete Files="@(ToDelete)" />
<!-- Rename deps file -->
<Move SourceFiles="$(SharedFxPublishDirectory)\SharedFx.deps.json"
DestinationFiles="$(SharedFxPublishDirectory)\$(SharedFxPackage).deps.json" />
<!-- Rename runtimeconfig.json file -->
<Move SourceFiles="$(SharedFxPublishDirectory)\SharedFx.runtimeconfig.json"
DestinationFiles="$(SharedFxPublishDirectory)\$(SharedFxPackage).runtimeconfig.json" />
<!-- Generate Runtime Graph -->
<PropertyGroup>
<RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('Windows'))">win</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx</RuntimeGraphGeneratorRuntime>
</PropertyGroup>
<ItemGroup>
<SharedFxAssetsFile Include="$(SharedFxWorkDirectory)**\project.assets.json" />
</ItemGroup>
<ProcessSharedFrameworkDeps
AssetsFilePath="@(SharedFxAssetsFile)"
DepsFilePath="$(SharedFxPublishDirectory)\$(SharedFxPackage).deps.json"
Runtime="$(RuntimeGraphGeneratorRuntime)" />
<!-- Generate .version file -->
<WriteLinesToFile
File="$(SharedFxPublishDirectory)\.version"
Lines="@(VersionLines)"
Overwrite="true" />
</Target>
<Target Name="ResolveSharedFxFiles" DependsOnTargets="PrepareForSharedFx">
<PropertyGroup>
<AppSharedFxProps>SharedFxPackage=Microsoft.AspNetCore.App</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);SharedFxWorkDirectory=$(AppSharedFxWorkDirectory)</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);SharedFxPublishDirectory=$(AppSharedFxPublishDirectory)</AppSharedFxProps>
<AllSharedFxProps>SharedFxPackage=Microsoft.AspNetCore.All</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);SharedFxWorkDirectory=$(AllSharedFxWorkDirectory)</AllSharedFxProps>
<AllSharedFxProps>$(AllSharedFxProps);SharedFxPublishDirectory=$(AllSharedFxPublishDirectory)</AllSharedFxProps>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_ResolveSharedFxFiles" Properties="$(AppSharedFxProps)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_ResolveSharedFxFiles" Properties="$(AllSharedFxProps)" />
<MakeDir Directories="$(SharedFxOutputPath)" />
</Target>
<Target Name="PrepareForCrossGen" DependsOnTargets="PrepareForSharedFx;ResolveSharedFxFiles">
<PropertyGroup>
<RuntimePackageName>Microsoft.NETCore.App</RuntimePackageName>
<CrossGenTool>crossgen</CrossGenTool>
<CrossGenTool Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(CrossGenTool).exe</CrossGenTool>
</PropertyGroup>
<!-- Determine runtime location (via .App shared framework) -->
<MSBuild Projects="$(AppSharedFxWorkDirectory)SharedFx.csproj" Targets="GetPackageDefinitions" >
<Output TaskParameter="TargetOutputs" ItemName="PackageDefinitions" />
</MSBuild>
<ItemGroup>
<RuntimePackage Include="@(PackageDefinitions)" Condition="$([System.String]::new('%(PackageDefinitions.Name)').Contains('runtime')) AND $([System.String]::new('%(PackageDefinitions.Name)').Contains('$(RuntimePackageName)'))" />
<RuntimePackageFiles Include="%(RuntimePackage.ResolvedPath)\runtimes\**\*" />
<CrossGenToolFile Include="%(RuntimePackage.ResolvedPath)\**\$(CrossGenTool)" />
</ItemGroup>
<Error Text="Could not identify the runtime package for $(SharedFXRid)" Condition="@(RuntimePackage->Count()) == 0" />
<!-- Create tool directory with crossgen executable and runtime assemblies -->
<Copy SourceFiles="@(RuntimePackageFiles);@(CrossGenToolFile)" DestinationFolder="$(SharedFxCrossGenToolDirectory)"/>
<ItemGroup>
<ClrJitAssembly Include="$(SharedFxCrossGenToolDirectory)\**\$(LibPrefix)clrjit$(LibExtension)" />
</ItemGroup>
<Error Text="Expected to resolve a single runtime package but instead resolved @(RuntimePackage->Count()) with identities %(RuntimePackage.Identity)" Condition="'@(RuntimePackage->Count())' != 1" />
<Error Text="Could not find crossgen in %(RuntimePackage.ResolvedPath)" Condition="@(CrossGenToolFile->Count()) == 0" />
<Error Text="Expected to resolve a single clr jit assembly but instead resolved @(ClrJitAssembly->Count()) with identities %(ClrJitAssembly.Identity)" Condition="'@(ClrJitAssembly->Count())' != 1" />
<!-- Gather details on published assemblies -->
<MSBuild Projects="$(AppSharedFxWorkDirectory)SharedFx.csproj"
Targets="GetPublishAssemblies"
Properties="RuntimeIdentifier=$(SharedFxRestoreRid);SelfContained=false" >
<Output TaskParameter="TargetOutputs" ItemName="AppPublishAssemblies" />
</MSBuild>
<MSBuild Projects="$(AllSharedFxWorkDirectory)SharedFx.csproj"
Targets="GetPublishAssemblies"
Properties="RuntimeIdentifier=$(SharedFxRestoreRid);SelfContained=false" >
<Output TaskParameter="TargetOutputs" ItemName="AllPublishAssemblies" />
</MSBuild>
<ItemGroup>
<IgnoredAssemblies Include="@(AppPublishAssemblies);@(AllPublishAssemblies)" Condition="'%(AssetType)' == 'native' OR '%(AssetType)' == 'resources'" />
<_AppRuntimeAssemblies Include="@(AppPublishAssemblies)" Condition="'%(AssetType)' == 'runtime'">
<SymbolsPackageFilename>%(PackageName).%(PackageVersion).symbols.nupkg</SymbolsPackageFilename>
<PortablePDB>%(RootDir)%(Directory)%(Filename).pdb</PortablePDB>
</_AppRuntimeAssemblies>
<_AllRuntimeAssemblies Include="@(AllPublishAssemblies)" Exclude="@(_AppRuntimeAssemblies)" Condition="'%(AssetType)' == 'runtime'">
<SymbolsPackageFilename>%(PackageName).%(PackageVersion).symbols.nupkg</SymbolsPackageFilename>
<PortablePDB>%(RootDir)%(Directory)%(Filename).pdb</PortablePDB>
</_AllRuntimeAssemblies>
<OtherAssemblies Include="@(AppPublishAssemblies);@(AllPublishAssemblies)" Exclude="@(IgnoredAssemblies);@(_AppRuntimeAssemblies);@(_AllRuntimeAssemblies)" />
<_AssembliesToCrossgen Include="$(SharedFxIntermediateOutputPath)**\*.dll" />
</ItemGroup>
<RepoTasks.ResolveSymbolsRecursivePath Symbols="@(_AppRuntimeAssemblies)">
<Output TaskParameter="Symbols" ItemName="AppRuntimeAssemblies" />
</RepoTasks.ResolveSymbolsRecursivePath>
<RepoTasks.ResolveSymbolsRecursivePath Symbols="@(_AllRuntimeAssemblies)">
<Output TaskParameter="Symbols" ItemName="AllRuntimeAssemblies" />
</RepoTasks.ResolveSymbolsRecursivePath>
<Error Text="Unaccounted shared framework assemblies found: @(OtherAssemblies). Assemblies must be included as runtime assemblies or marked as ignored." Condition="'@(OtherAssemblies)' != ''" />
<!-- Compute the intersection of crossgen candidates and native/resources assemblies as the set of assemblies to skip crossgen -->
<CreateItem Include="@(_AssembliesToCrossgen)" Condition="'%(Filename)' != ''and '@(IgnoredAssemblies)' != ''">
<Output TaskParameter="Include" ItemName="AssembliesToRemove"/>
</CreateItem>
<!-- Resolve list of assemblies to crossgen -->
<ItemGroup>
<AssembliesToCrossgen Include="@(_AssembliesToCrossgen)">
<Source>%(FullPath)</Source>
<Rsp>$(SharedFxCrossGenRspDirectory)%(RecursiveDir)%(Filename).rsp</Rsp>
<SymbolsRsp>$(SharedFxCrossGenRspDirectory)%(RecursiveDir)%(Filename).symbols.rsp</SymbolsRsp>
<Destination>$(SharedFxCrossGenDirectory)%(RecursiveDir)%(Filename)%(Extension)</Destination>
<Symbols>$(SharedFxCrossGenDirectory)%(RecursiveDir)</Symbols>
</AssembliesToCrossgen>
<AssembliesToCrossgen Remove="@(AssembliesToRemove)" />
</ItemGroup>
<!-- Compute the intersection of runtime assemblies and assemblies to crossgen to resolve the set of portablePDBs to publish -->
<CreateItem Include="@(AppRuntimeAssemblies)" Condition="'%(Filename)' != ''and '@(AssembliesToCrossgen)' != ''">
<Output TaskParameter="Include" ItemName="AppPortablePDBsToPublish"/>
</CreateItem>
<CreateItem Include="@(AllRuntimeAssemblies)" Condition="'%(Filename)' != ''and '@(AssembliesToCrossgen)' != ''">
<Output TaskParameter="Include" ItemName="AllPortablePDBsToPublish"/>
</CreateItem>
</Target>
<Target Name="CrossGenAssemblies"
DependsOnTargets="PrepareForCrossGen"
Inputs="@(AssembliesToCrossgen)"
Outputs="%(AssembliesToCrossgen.Destination)">
<ItemGroup>
<CrossGenArgs Include="-nologo" />
<CrossGenArgs Include="-readytorun" />
<CrossGenArgs Include="-in %(AssembliesToCrossgen.Source)" />
<CrossGenArgs Include="-out %(AssembliesToCrossgen.Destination)" />
<CrossGenArgs Include="-platform_assemblies_paths $(SharedFxCrossGenToolDirectory)$(PathSeparator)$(AppSharedFxPublishDirectory)$(PathSeparator)$(AllSharedFxPublishDirectory)" />
<CrossGenArgs Include="-JITPath %(ClrJitAssembly.FullPath)" />
</ItemGroup>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Rsp)'))" />
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Destination)'))" />
<WriteLinesToFile File="%(AssembliesToCrossgen.Rsp)" Lines="@(CrossGenArgs)" Overwrite="true" />
<Copy Condition="'$(CrossGenSharedFx)' == 'false'"
SourceFiles="%(AssembliesToCrossgen.Source)"
DestinationFiles="%(AssembliesToCrossgen.Destination)" />
<Exec Condition="'$(CrossGenSharedFx)' != 'false'"
Command="$(SharedFxCrossGenToolDirectory)$(CrossGenTool) @%(AssembliesToCrossgen.Rsp)"
EnvironmentVariables="COMPlus_PartialNGen=0" />
</Target>
<Target Name="CrossGenSymbols"
Condition=" '$(CrossGenSharedFxSymbols)' != 'false' "
DependsOnTargets="CrossGenAssemblies"
Inputs="@(AssembliesToCrossgen)"
Outputs="%(AssembliesToCrossgen.SymbolsRsp)">
<PropertyGroup>
<CrossGenSymbolsType>CreatePerfMap</CrossGenSymbolsType>
<CrossGenSymbolsType Condition="'$(OS)' == 'Windows_NT'">CreatePDB</CrossGenSymbolsType>
</PropertyGroup>
<ItemGroup>
<CrossGenSymbolsArgs Include="-nologo" />
<CrossGenSymbolsArgs Include="-readytorun" />
<CrossGenSymbolsArgs Include="-platform_assemblies_paths $(SharedFxCrossGenToolDirectory)$(PathSeparator)$(AppSharedFxPublishDirectory)$(PathSeparator)$(AllSharedFxPublishDirectory)" />
<CrossGenSymbolsArgs Include="-$(CrossGenSymbolsType)" />
<CrossGenSymbolsArgs Include="%(AssembliesToCrossgen.Symbols)" />
<CrossGenSymbolsArgs Include="%(AssembliesToCrossgen.Destination)" />
</ItemGroup>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(AssembliesToCrossgen.Symbols)'))" />
<WriteLinesToFile File="%(AssembliesToCrossgen.SymbolsRsp)" Lines="@(CrossGenSymbolsArgs)" Overwrite="true" />
<Exec Command="$(SharedFxCrossGenToolDirectory)$(CrossGenTool) @%(AssembliesToCrossgen.SymbolsRsp)" EnvironmentVariables="COMPlus_PartialNGen=0" />
</Target>
<Target Name="_BuildSharedFxSymbols">
<PropertyGroup>
<SymbolsPackageId>runtime.$(SharedFxRID).$(SymbolsNuspecIdSuffix)</SymbolsPackageId>
</PropertyGroup>
<!-- Create Layout -->
<Copy
SourceFiles="$(_TemplatesDir)SharedFxSymbols\SharedFrameworkSymbols.csproj"
DestinationFiles="$(SymbolsWorkDir)$(SymbolsPackageId).csproj"
OverwriteReadOnlyFiles="True" />
<!-- Produce symbols nupkg -->
<MSBuild Projects="$(SymbolsWorkDir)$(SymbolsPackageId).csproj"
Targets="Restore;Pack"
Properties="SymbolsWorkDir=$(SymbolsWorkDir);PackageId=$(SymbolsPackageId);PackageVersion=$(PackageVersion);PackageOutputPath=$(IntermediateDir);PackageDescription=$(Description)" />
<Copy
SourceFiles="$(IntermediateDir)$(SymbolsPackageId).$(PackageVersion).symbols.nupkg"
DestinationFolder="$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))symbols\" />
</Target>
<Target Name="PackSharedFx" DependsOnTargets="DefineSharedFxPrerequisites" >
<PropertyGroup>
<AppSharedFxCrossgenDirectory>$(SharedFxCrossGenDirectory)shared\Microsoft.AspNetCore.App\$(PackageVersion)\</AppSharedFxCrossgenDirectory>
<AllSharedFxCrossgenDirectory>$(SharedFxCrossGenDirectory)shared\Microsoft.AspNetCore.All\$(PackageVersion)\</AllSharedFxCrossgenDirectory>
<AppSharedFxSymbolsDirectory>$(_WorkRoot)Symbols\Microsoft.AspNetCore.App\</AppSharedFxSymbolsDirectory>
<AllSharedFxSymbolsDirectory>$(_WorkRoot)Symbols\Microsoft.AspNetCore.All\</AllSharedFxSymbolsDirectory>
</PropertyGroup>
<ItemGroup>
<AppCrossGenOutput Include="$(AppSharedFxCrossgenDirectory)**\*.dll" />
<AllCrossGenOutput Include="$(AllSharedFxCrossgenDirectory)**\*.dll" />
<AppCrossGenSymbols Include="$(AppSharedFxCrossgenDirectory)**\*" Exclude="@(AppCrossGenOutput)" />
<AllCrossGenSymbols Include="$(AllSharedFxCrossgenDirectory)**\*" Exclude="@(AllCrossGenOutput)" />
</ItemGroup>
<!-- Extract symbols package and copy over PDBs -->
<UnzipArchive
File="$(_SymbolsSourceDir)%(AppPortablePDBsToPublish.SymbolsPackageFilename)"
Destination="$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)"
Condition="Exists('$(_SymbolsSourceDir)%(AppPortablePDBsToPublish.SymbolsPackageFilename)')" />
<UnzipArchive
File="$(_SymbolsSourceDir)%(AllPortablePDBsToPublish.SymbolsPackageFilename)"
Destination="$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)"
Condition="Exists('$(_SymbolsSourceDir)%(AllPortablePDBsToPublish.SymbolsPackageFilename)')" />
<Copy
SourceFiles="$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)%(AppPortablePDBsToPublish.SymbolsRecursivePath)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True"
Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)\%(AppPortablePDBsToPublish.SymbolsRecursivePath)')" />
<Copy
SourceFiles="$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)%(AllPortablePDBsToPublish.SymbolsRecursivePath)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True"
Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)\%(AllPortablePDBsToPublish.SymbolsRecursivePath)')" />
<!-- Copy over DLLs and PDBs -->
<Copy
SourceFiles="%(AppPortablePDBsToPublish.PortablePDB)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True"
Condition="Exists('%(AppPortablePDBsToPublish.PortablePDB)')" />
<Copy
SourceFiles="%(AllPortablePDBsToPublish.PortablePDB)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True"
Condition="Exists('%(AllPortablePDBsToPublish.PortablePDB)')" />
<Copy
SourceFiles="@(AppCrossGenSymbols)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="@(AllCrossGenSymbols)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="$(AppSharedFxCrossgenDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="$(AllSharedFxCrossgenDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\$(SharedFrameworkTargetFramework)"
OverwriteReadOnlyFiles="True" />
<!-- Create symbols nupkg -->
<PropertyGroup>
<AppSymbolsArguments>SymbolsWorkDir=$(AppSharedFxSymbolsDirectory)</AppSymbolsArguments>
<AppSymbolsArguments>$(AppSymbolsArguments);SymbolsNuspecIdSuffix=Microsoft.AspNetCore.App</AppSymbolsArguments>
<AppSymbolsArguments>$(AppSymbolsArguments);Description=Symbol packages for Microsoft.AspNetCore.App shared framework</AppSymbolsArguments>
<AllSymbolsArguments>SymbolsWorkDir=$(AllSharedFxSymbolsDirectory)</AllSymbolsArguments>
<AllSymbolsArguments>$(AllSymbolsArguments);SymbolsNuspecIdSuffix=Microsoft.AspNetCore.All</AllSymbolsArguments>
<AllSymbolsArguments>$(AllSymbolsArguments);Description=Symbol packages for Microsoft.AspNetCore.All shared framework</AllSymbolsArguments>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_BuildSharedFxSymbols" Properties="$(AppSymbolsArguments)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_BuildSharedFxSymbols" Properties="$(AllSymbolsArguments)" />
<!-- Replace assemblies with crossgen output -->
<Copy
SourceFiles="$(AppSharedFxCrossgenDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
DestinationFiles="$(AppSharedFxPublishDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="$(AllSharedFxCrossgenDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
DestinationFiles="$(AllSharedFxPublishDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
OverwriteReadOnlyFiles="True" />
<ItemGroup>
<OutputZipFiles Include="$(SharedFxIntermediateOutputPath)**\*" />
</ItemGroup>
<!-- Create internal archive file -->
<Exec Condition="'$(ArchiveExtension)' == '.tar.gz'"
Command="tar -czf $(SharedFxOutputPath)$(SharedFxIntermediateArchiveBaseName)-$(PackageVersion)-$(SharedFxRID)$(ArchiveExtension) -C $(SharedFxIntermediateOutputPath) ." />
<ZipArchive Condition="'$(ArchiveExtension)' == '.zip'"
File="$(SharedFxOutputPath)$(SharedFxIntermediateArchiveBaseName)-$(PackageVersion)-$(SharedFxRID).zip"
SourceFiles="@(OutputZipFiles)"
WorkingDirectory="$(SharedFxIntermediateOutputPath)"
Overwrite="true"/>
</Target>
<Target Name="BuildSharedFx" DependsOnTargets="GeneratePropsFiles;ResolveSharedFxFiles;CrossGenAssemblies;CrossGenSymbols;PackSharedFx;TestSharedFx"/>
<Target Name="TestSharedFx" DependsOnTargets="GeneratePropsFiles;DefineSharedFxPrerequisites;ResolveCommitHash;InstallDotNet">
<PropertyGroup>
<UnitTestFxProject>$(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj</UnitTestFxProject>
<!-- The file path to the log file, from within the container -->
<UnitTestFxTrxLogFile>$(LogOutputDir)SharedFx-UnitTests-$(Version).trx</UnitTestFxTrxLogFile>
<!-- The trx file path from the perspective of the TeamCity agent -->
<UnitTestFxTrxPhysicalFilePath>$(UnitTestFxTrxLogFile)</UnitTestFxTrxPhysicalFilePath>
<UnitTestFxTrxPhysicalFilePath Condition="'$(HostMachineRepositoryRoot)' != ''">$(HostMachineRepositoryRoot)/artifacts/logs/SharedFx-UnitTests.trx</UnitTestFxTrxPhysicalFilePath>
<UnitTestFxTestProps>
DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);
SharedFxOutputPath=$(SharedFxIntermediateOutputPath);
RepositoryCommit=$(RepositoryCommit);
VSTestLogger=$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
SharedFxRuntimeIdentifier=$(SharedFXRid)
</UnitTestFxTestProps>
</PropertyGroup>
<MSBuild Projects="$(UnitTestFxProject)" Targets="Restore" Properties="_Dummy=restore;$(UnitTestFxTestProps)" />
<MSBuild Projects="$(UnitTestFxProject)" Targets="Build" Properties="$(UnitTestFxTestProps)">
<Output TaskParameter="TargetOutputs" ItemName="SharedFxTestAssembly" />
</MSBuild>
<RunDotNet Arguments="vstest;
--Framework:%(TargetFrameworkIdentifier),Version=v%(TargetFrameworkVersion);
--Logger:$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
%(SharedFxTestAssembly.Identity);
--;RunConfiguration.NoAutoReporters=true" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="VsTestExitCode" />
</RunDotNet>
<Message Text="##teamcity[importData type='vstest' path='$(UnitTestFxTrxPhysicalFilePath)']"
Importance="High"
Condition="'$(TEAMCITY_VERSION)' != '' AND Exists('$(UnitTestFxTrxLogFile)')" />
<Error Text="SharedFx.UnitTests failed with exit code '$(VsTestExitCode)'." Condition=" $(VsTestExitCode) != 0 " />
</Target>
</Project>