aspnetcore/build/SharedFx.targets

506 lines
28 KiB
XML

<Project>
<Import Project="common.props" />
<Import Project="SharedFx.props" />
<PropertyGroup>
<GetArtifactInfoDependsOn>$(GetArtifactInfoDependsOn);GetMetapackageArtifactInfo</GetArtifactInfoDependsOn>
</PropertyGroup>
<PropertyGroup>
<SharedFxOutputPath>$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))assets\Runtime\$(PackageVersion)\</SharedFxOutputPath>
</PropertyGroup>
<Target Name="GetMetapackageArtifactInfo">
<ItemGroup>
<_MetapackageProject Include="$(RepositoryRoot)src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj" />
<_MetapackageProject Include="$(RepositoryRoot)src\Microsoft.AspNetCore.App\Microsoft.AspNetCore.App.csproj" />
<_MetapackageProject Include="$(RepositoryRoot)src\Microsoft.AspNetCore.Analyzers\Microsoft.AspNetCore.Analyzers.csproj" />
</ItemGroup>
<MSBuild Projects="@(_MetapackageProject)"
Targets="GetArtifactInfo"
Properties="PackageOutputPath=$(BuildDir);BuildNumber=$(BuildNumber);DesignTimeBuild=true;IsFinalBuild=$(IsFinalBuild)">
<Output TaskParameter="TargetOutputs" ItemName="ArtifactInfo" />
</MSBuild>
</Target>
<Target Name="_BuildMetapackage" DependsOnTargets="ResolveRepoInfo">
<PropertyGroup>
<MetapackageSource>$(_MetapackageSrcRoot)$(MetapackageName)\</MetapackageSource>
<MetapackageWorkDirectory>$(_WorkRoot)$(MetapackageName)\</MetapackageWorkDirectory>
<CommonProps>Configuration=$(Configuration);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);AspNetUniverseBuildOffline=true</CommonProps>
<CommonProps>$(CommonProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion)</CommonProps>
<CommonProps>$(CommonProps);AppMetapackageVersion=$(PackageVersion)</CommonProps>
</PropertyGroup>
<Error
Message="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)"
LockToExactVersions="$(LockToExactVersions)"
BuildArtifacts="@(ArtifactInfo)"
PackageArtifacts="@(PackageArtifact)"
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;
LockToExactVersions=true
</AdditionalProperties>
</_MetapackageBuilderProject>
<_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>
MetapackageName=Microsoft.AspNetCore.All;
MetapackageReferenceType=AllMetapackage;
LockToExactVersions=false
</AdditionalProperties>
</_MetapackageBuilderProject>
<_MetapackageBuilderProject Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>
MetapackageName=Microsoft.AspNetCore.Analyzers;
MetapackageReferenceType=Analyzer;
LockToExactVersions=true
</AdditionalProperties>
</_MetapackageBuilderProject>
</ItemGroup>
<MSBuild
Projects="@(_MetapackageBuilderProject)"
Targets="_BuildMetapackage"
BuildInParallel="false" />
</Target>
<Target Name="DefineSharedFxPrerequisites">
<PropertyGroup>
<RIDIsAcceptable Condition="'%(AllSharedFxRIDs.Identity)' == '$(SharedFxRID)'">true</RIDIsAcceptable>
</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);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>SharedFxWorkDirectory=$(AppSharedFxWorkDirectory)</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion)</AppSharedFxProps>
<AppSharedFxProps>$(AppSharedFxProps);SharedFxPackage=Microsoft.AspNetCore.App</AppSharedFxProps>
<AllSharedFxProps>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>
<ItemGroup>
<VersionLines Include="$(CommitHash)" />
<VersionLines Include="$(PackageVersion)" />
</ItemGroup>
<!-- 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">
<!-- 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" />
<Exec Command="$(SharedFxCrossGenToolDirectory)$(CrossGenTool) @%(AssembliesToCrossgen.Rsp)" EnvironmentVariables="COMPlus_PartialNGen=0" />
</Target>
<Target Name="CrossGenSymbols"
Condition="$([MSBuild]::IsOSPlatform('Linux')) OR $([MSBuild]::IsOSPlatform('Windows'))"
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>
<ItemGroup>
<_SymbolFiles Include="$(SymbolsWorkDir)**\*.pdb;$(SymbolsWorkDir)**\*.map;$(SymbolsWorkDir)**\*.dll" />
<SymbolFiles Include="@(_SymbolFiles)">
<PackagePath>%(RecursiveDir)%(Filename)%(Extension)</PackagePath>
</SymbolFiles>
</ItemGroup>
<!-- Create Layout -->
<Copy
SourceFiles="$(_TemplatesDir)SharedFxSymbols\SharedFrameworkSymbols.nuspec"
DestinationFiles="$(SymbolsWorkDir)$(SymbolsPackageId).nuspec"
OverwriteReadOnlyFiles="True" />
<!-- Produce symbols nupkg -->
<PackNuspec NuspecPath="$(SymbolsWorkDir)$(SymbolsPackageId).nuspec"
OutputPath="$([MSBuild]::NormalizeDirectory($(ArtifactsDir)))symbols\$(SymbolsPackageId).$(PackageVersion).symbols.nupkg"
Properties="version=$(PackageVersion);id=$(SymbolsPackageId);description=$(Description);Configuration=$(Configuration)"
Overwrite="true"
PackageFiles="@(SymbolFiles)"
BasePath="$(SymbolsWorkDir)" />
</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\netcoreapp2.1"
OverwriteReadOnlyFiles="True"
Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AppPortablePDBsToPublish.SymbolsPackageFilename)\%(AppPortablePDBsToPublish.SymbolsRecursivePath)')" />
<Copy
SourceFiles="$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)%(AllPortablePDBsToPublish.SymbolsRecursivePath)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True"
Condition="Exists('$(_WorkRoot)SymbolsPackages\%(AllPortablePDBsToPublish.SymbolsPackageFilename)\%(AllPortablePDBsToPublish.SymbolsRecursivePath)')" />
<!-- Copy over DLLs and PDBs -->
<Copy
SourceFiles="%(AppPortablePDBsToPublish.PortablePDB)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True"
Condition="Exists('%(AppPortablePDBsToPublish.PortablePDB)')" />
<Copy
SourceFiles="%(AllPortablePDBsToPublish.PortablePDB)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True"
Condition="Exists('%(AllPortablePDBsToPublish.PortablePDB)')" />
<Copy
SourceFiles="@(AppCrossGenSymbols)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="@(AllCrossGenSymbols)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="$(AppSharedFxCrossgenDirectory)%(AppCrossGenOutput.RecursiveDir)%(AppCrossGenOutput.FileName)%(AppCrossGenOutput.Extension)"
DestinationFolder="$(AppSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
OverwriteReadOnlyFiles="True" />
<Copy
SourceFiles="$(AllSharedFxCrossgenDirectory)%(AllCrossGenOutput.RecursiveDir)%(AllCrossGenOutput.FileName)%(AllCrossGenOutput.Extension)"
DestinationFolder="$(AllSharedFxSymbolsDirectory)runtimes\$(SharedFxRID)\lib\netcoreapp2.1"
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 archive -->
<ZipArchive
File="$(SharedFxOutputPath)$(SharedFxIntermediateArchiveBaseName)-$(PackageVersion)-$(SharedFxRID).zip"
SourceFiles="@(OutputZipFiles)"
WorkingDirectory="$(SharedFxIntermediateOutputPath)"
Overwrite="true"/>
</Target>
<Target Name="BuildSharedFx" DependsOnTargets="GeneratePropsFiles;ResolveSharedFxFiles;CrossGenAssemblies;CrossGenSymbols;PackSharedFx"/>
</Project>