mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
* use arcade target * extra space * fixes generation of reference src from runtime projects * run target to get genapi * use referencePath to get references * adding GenerateReferenceSource target * added the target name
125 lines
6.5 KiB
XML
125 lines
6.5 KiB
XML
<Project>
|
|
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(TargetFramework)' != '$(NetCoreAppCurrent)'">
|
|
<PrepareProjectReferencesDependsOn>
|
|
AddRuntimeProjectReference;
|
|
$(PrepareProjectReferencesDependsOn);
|
|
</PrepareProjectReferencesDependsOn>
|
|
<ResolveReferencesDependsOn>
|
|
AddRuntimeProjectReference;
|
|
$(ResolveReferencesDependsOn);
|
|
</ResolveReferencesDependsOn>
|
|
<CleanDependsOn>
|
|
AddRuntimeProjectReference;
|
|
$(CleanDependsOn)
|
|
</CleanDependsOn>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<RuntimeProjectFile>$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'restore', 'runtime', 'runtime.depproj'))</RuntimeProjectFile>
|
|
</PropertyGroup>
|
|
|
|
<Target Name="AddRuntimeProjectReference"
|
|
Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '@(ReferenceFromRuntime)' != ''">
|
|
<Error Text="ReferenceFromRuntime may not be used from reference assemblies."
|
|
Condition="'$(IsReferenceAssembly)' == 'true' and '$(AllowReferenceFromRuntime)' != 'true'" />
|
|
|
|
<ItemGroup>
|
|
<ProjectReference Include="$(RuntimeProjectFile)">
|
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
<OutputItemType>_referencePathFromRestoredRuntime</OutputItemType>
|
|
</ProjectReference>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="GetFilesFromRuntime" Returns="@(RuntimeFiles)" DependsOnTargets="GetFilesFromCoreClr;GetFilesFromMono">
|
|
<ItemGroup>
|
|
<RuntimeFiles Include="@(RuntimeFiles)" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!--
|
|
The check must use != Mono because we don't consistently set this value to CoreCLR
|
|
https://github.com/dotnet/runtime/issues/32884
|
|
-->
|
|
<Target Name="GetFilesFromCoreCLR"
|
|
Condition="'$(RuntimeFlavor)' != 'Mono'"
|
|
Returns="@(RuntimeFiles)"
|
|
DependsOnTargets="ResolveRuntimeFilesFromLocalBuild" />
|
|
|
|
<Target Name="GetFilesFromMono"
|
|
Condition="'$(RuntimeFlavor)' == 'Mono'"
|
|
Returns="@(RuntimeFiles)"
|
|
DependsOnTargets="ResolveRuntimeFilesFromLocalBuild" />
|
|
|
|
<Target Name="FilterReferenceFromRuntime"
|
|
AfterTargets="ResolveProjectReferences"
|
|
Condition="'@(ReferenceFromRuntime)' != ''">
|
|
|
|
<Error Condition="'$(IsReferenceAssembly)' == 'true' and '$(AllowReferenceFromRuntime)' != 'true'" Text="ReferenceFromRuntime may not be used from reference assemblies." />
|
|
|
|
<MSBuild Projects="$(MSBuildProjectFile)" Targets="GetFilesFromRuntime" Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
|
|
<Output TaskParameter="TargetOutputs" ItemName="RuntimeFiles" />
|
|
</MSBuild>
|
|
|
|
<ItemGroup>
|
|
<_referencePathFromRuntime Include="@(RuntimeFiles)" Private="false" />
|
|
<_referencePathFromRuntime Include="@(_referencePathFromRestoredRuntime)" Private="false" />
|
|
<!-- If this is a test project, also use the $(RuntimePath) to find a @(ReferenceFromRuntime) assembly. -->
|
|
<_referencePathFromRuntime Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'" />
|
|
<!-- transform to filename in order to intersect -->
|
|
<_referencePathFromRuntimeByFileName Include="@(_referencePathFromRuntime->'%(FileName)')" Condition="'%(_referencePathFromRuntime.Extension)' == '.dll'" >
|
|
<ReferencePath>%(Identity)</ReferencePath>
|
|
</_referencePathFromRuntimeByFileName>
|
|
</ItemGroup>
|
|
|
|
<RemoveDuplicates Inputs="@(_referencePathFromRuntimeByFileName)">
|
|
<Output TaskParameter="Filtered" ItemName="_referencePathFromRuntimeByFileNameFiltered" />
|
|
</RemoveDuplicates>
|
|
|
|
<ItemGroup>
|
|
|
|
<!-- intersect with ReferenceFromRuntime -->
|
|
<_filteredReferencePathFromRuntimeByFileName Include="@(_referencePathFromRuntimeByFileNameFiltered)"
|
|
Condition="'@(_referencePathFromRuntimeByFileNameFiltered)' == '@(ReferenceFromRuntime)' and '%(Identity)' != ''">
|
|
<Aliases>@(ReferenceFromRuntime->'%(Aliases)')</Aliases>
|
|
</_filteredReferencePathFromRuntimeByFileName>
|
|
|
|
<_remainingReferenceFromRuntime Include="@(ReferenceFromRuntime)" Exclude="@(_filteredReferencePathFromRuntimeByFileName)" />
|
|
|
|
<!-- Fallback and check for native images for the references as well -->
|
|
<_remainingReferenceFromRuntimeWithNI Include="@(_remainingReferenceFromRuntime->'%(Identity).ni')">
|
|
<OriginalReferenceFromRuntime>%(Identity)</OriginalReferenceFromRuntime>
|
|
</_remainingReferenceFromRuntimeWithNI>
|
|
|
|
<_filteredReferencePathFromRuntimeByFileName Include="@(_referencePathFromRuntimeByFileNameFiltered)"
|
|
Condition="'@(_referencePathFromRuntimeByFileNameFiltered)' == '@(_remainingReferenceFromRuntimeWithNI)' and '%(Identity)' != ''">
|
|
<Aliases>@(_remainingReferenceFromRuntimeWithNI->'%(Aliases)')</Aliases>
|
|
</_filteredReferencePathFromRuntimeByFileName>
|
|
|
|
<_missingReferenceFromRuntime Include="@(_remainingReferenceFromRuntimeWithNI)" Exclude="@(_filteredReferencePathFromRuntimeByFileName)" />
|
|
|
|
<!-- transform back to path -->
|
|
<!-- We are adding two items(with and without aliases) for references having Aliases. The major reason behind this to not use the Aliases for all the types in that reference. -->
|
|
<!-- We can't use a Reference item for both since only the first one will be kept. -->
|
|
<!-- Aliases provides no way to encode both an alias and a non-aliased reference : https://github.com/dotnet/roslyn/issues/42604 -->
|
|
<!-- Use ReferencePath for the second reference so it will still be passed to the compiler. -->
|
|
<Reference Include="@(_filteredReferencePathFromRuntimeByFileName->'%(ReferencePath)')" />
|
|
<_aliasedReferencePathFromRuntime Include="@(_filteredReferencePathFromRuntimeByFileName->'%(ReferencePath)')" Condition="'%(_filteredReferencePathFromRuntimeByFileName.Aliases)' != ''" />
|
|
<ReferencePath Include="@(_aliasedReferencePathFromRuntime)" Aliases=""/>
|
|
</ItemGroup>
|
|
|
|
<Error Condition="'@(_missingReferenceFromRuntime)' != ''"
|
|
Text="Could not resolve ReferenceFromRuntime item(s) '%(_missingReferenceFromRuntime.OriginalReferenceFromRuntime)' from '$(RuntimeProjectFile)'." />
|
|
</Target>
|
|
|
|
<Target Name="RemoveAliasedReferenceFromRuntime"
|
|
AfterTargets="CoreCompile"
|
|
Condition="'@(_aliasedReferencePathFromRuntime)' != ''">
|
|
<!-- SDK's GenerateBuildDependencyFile will break when they encounter two identical reference paths, fix by removing the aliased ones -->
|
|
<ItemGroup>
|
|
<ReferencePath Remove="@(_aliasedReferencePathFromRuntime)"/>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
</Project>
|