336 lines
16 KiB
XML
336 lines
16 KiB
XML
<!--
|
|
This file defines targets for building a shared framework.
|
|
This targets file should only be imported by .shfxproj files.
|
|
-->
|
|
<Project>
|
|
|
|
<Import Project="..\..\build\tasks\RepoTasks.tasks" />
|
|
|
|
<PropertyGroup>
|
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
|
|
|
<CoreBuildDependsOn>
|
|
BuildOnlySettings;
|
|
PrepareForBuild;
|
|
PreBuildEvent;
|
|
ResolveReferences;
|
|
GenerateSharedFxVersionsFile;
|
|
PrepareForPublish;
|
|
ComputeAndCopyFilesToPublishDirectory;
|
|
GeneratePublishDependencyFile;
|
|
GenerateSharedFxDependencyFile;
|
|
GeneratePublishRuntimeConfigurationFile;
|
|
CopySharedFxToOutput;
|
|
CollectSharedFxOutput;
|
|
PostBuildEvent;
|
|
GetTargetPath;
|
|
</CoreBuildDependsOn>
|
|
|
|
<CollectOutputSharedFxDependsOn Condition=" '$(CrossGenOutput)' != 'false' ">
|
|
PrepareForCrossGen;
|
|
CrossGenAssemblies;
|
|
</CollectOutputSharedFxDependsOn>
|
|
|
|
<CollectOutputSharedFxDependsOn Condition=" '$(CrossgenSymbolsOutput)' != 'false' ">
|
|
$(CollectOutputSharedFxDependsOn);
|
|
CrossGenSymbols;
|
|
</CollectOutputSharedFxDependsOn>
|
|
|
|
<PrepareForBuildDependsOn>
|
|
PrepareOutputPaths;
|
|
</PrepareForBuildDependsOn>
|
|
|
|
<ResolveReferencesDependsOn>
|
|
BeforeResolveReferences;
|
|
AssignProjectConfiguration;
|
|
ResolveProjectReferences;
|
|
FindInvalidProjectReferences;
|
|
AfterResolveReferences
|
|
</ResolveReferencesDependsOn>
|
|
|
|
<!-- The name of the shared framework. -->
|
|
<SharedFxName Condition=" '$(SharedFxName)' == '' ">$(MSBuildProjectName)</SharedFxName>
|
|
|
|
<!--
|
|
Defines the base RID for a vertical of related runtimes, e.g. Windows, macOS, Linux.
|
|
This is used during runtime graph generation to determine which RIDs to include in the .deps.json file.
|
|
-->
|
|
<BaseSharedFxRid Condition="$(SharedFxRid.StartsWith('win'))">win</BaseSharedFxRid>
|
|
<BaseSharedFxRid Condition="$(SharedFxRid.StartsWith('osx'))">osx</BaseSharedFxRid>
|
|
<BaseSharedFxRid Condition="$(SharedFxRid.StartsWith('linux')) AND ! $(SharedFxRid.StartsWith('linux-musl')) ">linux</BaseSharedFxRid>
|
|
<BaseSharedFxRid Condition="$(SharedFxRid.StartsWith('linux-musl'))">linux-musl</BaseSharedFxRid>
|
|
<BaseSharedFxRid Condition="'$(BaseSharedFxRid)' == '' ">unix</BaseSharedFxRid>
|
|
|
|
<LibPrefix Condition=" '$(BaseSharedFxRid)' != 'win' ">lib</LibPrefix>
|
|
<LibExtension>.so</LibExtension>
|
|
<LibExtension Condition=" '$(BaseSharedFxRid)' == 'win' ">.dll</LibExtension>
|
|
<LibExtension Condition=" '$(BaseSharedFxRid)' == 'osx' ">.dylib</LibExtension>
|
|
<ExeExtension Condition=" '$(BaseSharedFxRid)' == 'win' ">.exe</ExeExtension>
|
|
<!-- 3B = semicolon in ASCII -->
|
|
<PathSeparator Condition="'$(PathSeparator)' == ''">:</PathSeparator>
|
|
<PathSeparator Condition=" '$(BaseSharedFxRid)' == 'win' ">%3B</PathSeparator>
|
|
|
|
<IntermediateOutputPath>$(IntermediateOutputPath)$(SharedFxRid)\</IntermediateOutputPath>
|
|
|
|
<!-- Override the SDK Default for this location for copying published output. -->
|
|
<PublishDir>$(IntermediateOutputPath)u\</PublishDir>
|
|
|
|
<!-- If symbols generation is disabled, there is no use in producing a symbols.nupkg files. -->
|
|
<IncludeSymbols Condition="'$(CrossgenSymbolsOutput)' == 'false'">false</IncludeSymbols>
|
|
|
|
<MetadataOutputPath Condition="'$(MetadataOutputPath)' == ''">$(OutputPath)files\</MetadataOutputPath>
|
|
<SymbolsOutputPath Condition="'$(SymbolsOutputPath)' == ''">$(OutputPath)symbols\</SymbolsOutputPath>
|
|
<NativeAssetsOutputPath Condition="'$(NativeAssetsOutputPath)' == ''">$(OutputPath)native\</NativeAssetsOutputPath>
|
|
<RuntimeAssetsOutputPath Condition="'$(RuntimeAssetsOutputPath)' == ''">$(OutputPath)lib\$(TargetFramework)\</RuntimeAssetsOutputPath>
|
|
|
|
<CrossGenToolDir>$(IntermediateOutputPath)crossgen\</CrossGenToolDir>
|
|
|
|
<!-- Map BaseSharedFrameworkName into properties used by the SDK to determine publish output trimming and deps.json generation -->
|
|
<MicrosoftNETPlatformLibrary>$(BaseSharedFrameworkName)</MicrosoftNETPlatformLibrary>
|
|
<!-- Prevents runtimeconfig.dev.json from ending up in publish output. -->
|
|
<ProjectRuntimeConfigDevFilePath>$(IntermediateOutputPath)$(SharedFxName).runtimeconfig.dev.json</ProjectRuntimeConfigDevFilePath>
|
|
<!-- Redirects the output of GeneratePublishDependencyFile into obj/ because we need to do post-processing on the .deps.json file -->
|
|
<ProjectDepsFilePath>$(IntermediateOutputPath)$(SharedFxName).project.deps.json</ProjectDepsFilePath>
|
|
<PublishDepsFilePath>$(IntermediateOutputPath)$(SharedFxName).publish.deps.json</PublishDepsFilePath>
|
|
|
|
<!-- The output path of generated files -->
|
|
<ProjectRuntimeConfigFilePath>$(MetadataOutputPath)$(SharedFxName).runtimeconfig.json</ProjectRuntimeConfigFilePath>
|
|
<SharedFxDepsFilePath>$(MetadataOutputPath)$(SharedFxName).deps.json</SharedFxDepsFilePath>
|
|
<VersionFileOutputPath>$(MetadataOutputPath).version</VersionFileOutputPath>
|
|
</PropertyGroup>
|
|
|
|
<ItemDefinitionGroup>
|
|
<!-- Defines different types of project references. -->
|
|
<FrameworkProjectReference>
|
|
<OutputItemType>_ResolvedFrameworkProjectReferencePaths</OutputItemType>
|
|
</FrameworkProjectReference>
|
|
|
|
<PackageProjectReference>
|
|
<OutputItemType>_ResolvedPackageProjectReferencePaths</OutputItemType>
|
|
</PackageProjectReference>
|
|
|
|
<TargetPathWithTargetPlatformMoniker>
|
|
<!--
|
|
This lists all folders of assets which should be collected into the same folder in a shared framework installer.
|
|
This is set on this item group so it flows across project references into installer projects.
|
|
-->
|
|
<InstallerAssetPaths>
|
|
$(MetadataOutputPath);
|
|
$(RuntimeAssetsOutputPath);
|
|
$(NativeAssetsOutputPath);
|
|
</InstallerAssetPaths>
|
|
<MetadataOutputPath>$(MetadataOutputPath)</MetadataOutputPath>
|
|
<RuntimeAssetsOutputPath>$(RuntimeAssetsOutputPath)</RuntimeAssetsOutputPath>
|
|
<NativeAssetsOutputPath>$(NativeAssetsOutputPath)</NativeAssetsOutputPath>
|
|
<SharedFxName>$(SharedFxName)</SharedFxName>
|
|
<PackageId>$(PackageId)</PackageId>
|
|
</TargetPathWithTargetPlatformMoniker>
|
|
</ItemDefinitionGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.NETCore.App" Version="$(RuntimeFrameworkVersion)">
|
|
<IsImplicitlyDefined>true</IsImplicitlyDefined>
|
|
<Publish>true</Publish>
|
|
<PrivateAssets>All</PrivateAssets>
|
|
<ExcludeAssets>Native</ExcludeAssets>
|
|
<AllowExplicitVersion>true</AllowExplicitVersion>
|
|
</PackageReference>
|
|
|
|
<PackageReference Include="@(Dependency)">
|
|
<IncludeAssets>Runtime;Native</IncludeAssets>
|
|
</PackageReference>
|
|
|
|
<ProjectReference Include="@(FrameworkProjectReference)" />
|
|
<ProjectReference Include="@(PackageProjectReference)" />
|
|
</ItemGroup>
|
|
|
|
<!-- Check some required properties before building a shared framework/ -->
|
|
<Target Name="_CheckForRequiredFxProperties" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
|
|
<Error Condition=" '$(BaseSharedFrameworkName)' == '' "
|
|
Text="Missing required property: BaseSharedFrameworkName. Shared frameworks must specify which framework is used at the base." />
|
|
|
|
<Error Condition=" '$(SharedFxRid)' == '' "
|
|
Text="Missing required property: SharedFxRid. Shared frameworks are rid-specific, so this must be set." />
|
|
|
|
<ItemGroup>
|
|
<_UnknownRid Remove="@(_UnknownRid)" />
|
|
<_UnknownRid Include="$(SharedFxRid)" Exclude="$(SupportedRuntimeIdentifiers)" />
|
|
</ItemGroup>
|
|
|
|
<Error Condition=" '@(_UnknownRid)' != '' "
|
|
Text=""$(SharedFxRid)" not acceptable runtime identifier. Please specify an acceptable value: {$(SupportedRuntimeIdentifiers)}." />
|
|
|
|
<Message Importance="High" Text="Building $(SharedFxName) (fx: $(SharedFxRid))" />
|
|
</Target>
|
|
|
|
<Target Name="PrepareOutputPaths">
|
|
<MakeDir Directories="$(MetadataOutputPath);$(SymbolsOutputPath);$(NativeAssetsOutputPath);$(RuntimeAssetsOutputPath)" />
|
|
</Target>
|
|
|
|
<!-- Generates the .version file in the shared framework -->
|
|
<Target Name="GenerateSharedFxVersionsFile">
|
|
<ItemGroup>
|
|
<VersionLines Include="$(RepositoryCommit)" />
|
|
<VersionLines Include="$(PackageVersion)" />
|
|
</ItemGroup>
|
|
|
|
<WriteLinesToFile
|
|
File="$(VersionFileOutputPath)"
|
|
Lines="@(VersionLines)"
|
|
Overwrite="true" />
|
|
</Target>
|
|
|
|
<!-- Generates the .deps.json file for a shared framework. -->
|
|
<Target Name="GenerateSharedFxDependencyFile"
|
|
Inputs="$(PublishDepsFilePath);$(ProjectAssetsFile);$(MSBuildAllProjects)"
|
|
Outputs="$(SharedFxDepsFilePath)">
|
|
<ProcessSharedFrameworkDeps
|
|
FrameworkName="$(SharedFxName)"
|
|
AssetsFilePath="$(ProjectAssetsFile)"
|
|
DepsFilePath="$(PublishDepsFilePath)"
|
|
OutputPath="$(SharedFxDepsFilePath)"
|
|
PackagesToRemove="@(_ResolvedFrameworkProjectReferencePaths->'%(PackageId)')"
|
|
ResolvedPackageProjectReferences="@(_ResolvedPackageProjectReferencePaths)"
|
|
Runtime="$(BaseSharedFxRid)" />
|
|
</Target>
|
|
|
|
<!-- Optimizes shared framework output -->
|
|
<Target Name="CollectSharedFxOutput" DependsOnTargets="$(CollectOutputSharedFxDependsOn)">
|
|
<Message Importance="High" Text="$(SharedFxName) (fx: $(SharedFxRid)) -> $(OutputPath)" />
|
|
</Target>
|
|
|
|
<!-- Prepare the project to run crossgen. -->
|
|
<Target Name="CopySharedFxToOutput" DependsOnTargets="RunResolvePackageDependencies;RunResolvePublishAssemblies">
|
|
<ItemGroup>
|
|
<NativeAssetsToPublish Include="@(ResolvedAssembliesToPublish)" Condition="'%(AssetType)' == 'native' " />
|
|
<ResourceAssetsToPublish Include="@(ResolvedAssembliesToPublish)" Condition="'%(AssetType)' == 'resources'" />
|
|
<RuntimeAssetsToPublish Include="@(ResolvedAssembliesToPublish)" Condition="'%(AssetType)' == 'runtime'" />
|
|
<OtherAssemblies Include="@(ResolvedAssembliesToPublish)" Exclude="@(NativeAssetsToPublish);@(ResourceAssetsToPublish);@(RuntimeAssetsToPublish)" />
|
|
</ItemGroup>
|
|
|
|
<Error Text="Unaccounted shared framework assemblies found: @(OtherAssemblies). These files have an unknown asset type." Condition="'@(OtherAssemblies)' != ''" />
|
|
|
|
<Copy Condition=" '$(CrossGenOutput)' != 'true' "
|
|
SourceFiles="@(RuntimeAssetsToPublish)" DestinationFiles="@(RuntimeAssetsToPublish->'$(RuntimeAssetsOutputPath)%(DestinationSubPath)')" />
|
|
<Copy SourceFiles="@(NativeAssetsToPublish)" DestinationFiles="@(NativeAssetsToPublish->'$(NativeAssetsOutputPath)%(DestinationSubPath)')" />
|
|
<Copy SourceFiles="@(ResourceAssetsToPublish)" DestinationFiles="@(ResourceAssetsToPublish->'$(RuntimeAssetsOutputPath)%(DestinationSubPath)')" />
|
|
</Target>
|
|
|
|
<Target Name="PrepareForCrossGen" DependsOnTargets="RunResolvePackageDependencies;RunResolvePublishAssemblies">
|
|
<MakeDir Directories="$(CrossGenToolDir)" />
|
|
|
|
<PropertyGroup>
|
|
<RuntimePackageName>Microsoft.NETCore.App</RuntimePackageName>
|
|
<CrossGenTool>crossgen</CrossGenTool>
|
|
<CrossGenTool Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(CrossGenTool).exe</CrossGenTool>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<RuntimePackage Include="@(PackageDefinitions)" Condition="$([System.String]::new('%(PackageDefinitions.Name)').Contains('runtime')) AND $([System.String]::new('%(PackageDefinitions.Name)').Contains('$(RuntimePackageName)'))" />
|
|
</ItemGroup>
|
|
|
|
<Error Text="Could not identify the crossgen package for $(SharedFxRid)" Condition="@(RuntimePackage->Count()) == 0" />
|
|
|
|
<ItemGroup>
|
|
<RuntimePackageFiles Include="%(RuntimePackage.ResolvedPath)\runtimes\**\*" />
|
|
<CrossGenToolFile Include="%(RuntimePackage.ResolvedPath)\**\$(CrossGenTool)" />
|
|
</ItemGroup>
|
|
|
|
<!-- Create tool directory with crossgen executable and runtime assemblies -->
|
|
<Copy SourceFiles="@(RuntimePackageFiles);@(CrossGenToolFile)" DestinationFolder="$(CrossGenToolDir)"/>
|
|
|
|
<ItemGroup>
|
|
<ClrJitAssembly Include="$(CrossGenToolDir)\**\$(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" />
|
|
|
|
<!-- Resolve list of assemblies to crossgen -->
|
|
<ItemGroup>
|
|
<AssembliesToCrossgen Include="@(RuntimeAssetsToPublish)">
|
|
<Source>%(FullPath)</Source>
|
|
<Rsp>$(IntermediateOutputPath)%(RecursiveDir)%(Filename).rsp</Rsp>
|
|
<SymbolsRsp>$(IntermediateOutputPath)%(RecursiveDir)%(Filename).symbols.rsp</SymbolsRsp>
|
|
<SymbolsOutputPath>$(SymbolsOutputPath)%(RecursiveDir)%(Filename).ni.pdb</SymbolsOutputPath>
|
|
<Destination>$(RuntimeAssetsOutputPath)%(RecursiveDir)%(Filename)%(Extension)</Destination>
|
|
<Symbols>$(SymbolsOutputPath)%(RecursiveDir)</Symbols>
|
|
</AssembliesToCrossgen>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!--
|
|
Run the crossgen tool.
|
|
This uses .rsp files to get around OS limitations in the maximum number of characters that can be passed in on command-line.
|
|
-->
|
|
<Target Name="CrossGenAssemblies"
|
|
DependsOnTargets="CopySharedFxToOutput;ResolveReferences"
|
|
Inputs="@(AssembliesToCrossgen)"
|
|
Outputs="%(AssembliesToCrossgen.Destination)">
|
|
|
|
<ItemGroup>
|
|
<!-- These are the paths used by crossgen to find assemblies that are expected to exist at runtime in the shared frameworks. -->
|
|
<_PlatformAssemblyPaths Remove="@(_PlatformAssemblyPaths)" />
|
|
<_PlatformAssemblyPaths Include="$(CrossGenToolDir)" />
|
|
<_PlatformAssemblyPaths Include="$(PublishDir)" />
|
|
<_PlatformAssemblyPaths Include="%(_ResolvedFrameworkProjectReferencePaths.RuntimeAssetsOutputPath)" Condition="'%(_ResolvedFrameworkProjectReferencePaths.RuntimeAssetsOutputPath)' != ''" />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<PlatformAssemblyPaths>@(_PlatformAssemblyPaths->Distinct(), '$(PathSeparator)')</PlatformAssemblyPaths>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<CrossGenArgs Include="-nologo" />
|
|
<CrossGenArgs Include="-readytorun" />
|
|
<CrossGenArgs Include="-in %(AssembliesToCrossgen.Source)" />
|
|
<CrossGenArgs Include="-out %(AssembliesToCrossgen.Destination)" />
|
|
<CrossGenArgs Include="-platform_assemblies_paths $(PlatformAssemblyPaths)" />
|
|
<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="$(CrossGenToolDir)$(CrossGenTool) @%(AssembliesToCrossgen.Rsp)"
|
|
EnvironmentVariables="COMPlus_PartialNGen=0"
|
|
IgnoreStandardErrorWarningFormat="true"
|
|
StandardOutputImportance="Normal" />
|
|
</Target>
|
|
|
|
<Target Name="CrossGenSymbols"
|
|
DependsOnTargets="CrossGenAssemblies"
|
|
Inputs="@(AssembliesToCrossgen)"
|
|
Outputs="%(AssembliesToCrossgen.SymbolsOutputPath)">
|
|
<PropertyGroup>
|
|
<CrossGenSymbolsType>CreatePerfMap</CrossGenSymbolsType>
|
|
<CrossGenSymbolsType Condition="'$(OS)' == 'Windows_NT'">CreatePDB</CrossGenSymbolsType>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<CrossGenSymbolsArgs Include="-nologo" />
|
|
<CrossGenSymbolsArgs Include="-readytorun" />
|
|
<CrossGenSymbolsArgs Include="-platform_assemblies_paths $(PlatformAssemblyPaths)" />
|
|
<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="$(CrossGenToolDir)$(CrossGenTool) @%(AssembliesToCrossgen.SymbolsRsp)"
|
|
EnvironmentVariables="COMPlus_PartialNGen=0"
|
|
IgnoreStandardErrorWarningFormat="true"
|
|
StandardOutputImportance="Normal" />
|
|
</Target>
|
|
|
|
<Target Name="CreateManifestResourceNames" />
|
|
</Project>
|