2017-02-02 02:58:41 +03:00
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="AddReferenceFromRuntimeForTests"
AfterTargets="ResolveAssemblyReferences"
Condition="'$(IsTestProject)'=='true' AND '@(ReferenceFromRuntime)' != ''">
<ItemGroup>
<!-- tests can use anything from the RuntimePath -->
<ReferencePath Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" />
2017-09-08 20:47:47 +03:00
<ReferenceCopyLocalPaths Condition="'%(ReferenceFromRuntime.Private)' == 'true'" Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" />
2017-02-02 02:58:41 +03:00
</ItemGroup>
</Target>
2017-02-07 22:26:01 +03:00
<Target Name="AddRuntimeProjectReference"
BeforeTargets="AddProjectReferencesDynamically"
2017-02-02 02:58:41 +03:00
Condition="'$(IsTestProject)'!='true' AND '@(ReferenceFromRuntime)' != ''">
2017-06-29 07:15:33 +03:00
<Error Condition="('$(IsReferenceAssembly)' != 'true' OR '$(AllowReferenceFromRuntime)' == 'true') AND '$(RuntimeProjectFile)' == ''" Text="RuntimeProjectFile must be specified when using ReferenceFromRuntime from source projects." />
<Error Condition="'$(IsReferenceAssembly)' == 'true' AND '$(AllowReferenceFromRuntime)' != 'true'" Text="ReferenceFromRuntime may not be used from reference assemblies." />
2017-02-02 02:58:41 +03:00
<ItemGroup>
<ProjectReference Include="$(RuntimeProjectFile)">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>_referencePathFromRuntime</OutputItemType>
</ProjectReference>
</ItemGroup>
</Target>
2017-02-07 22:26:01 +03:00
<Target Name="FilterReferenceFromRuntime"
2017-02-02 02:58:41 +03:00
AfterTargets="ResolveProjectReferences"
Condition="'$(IsTestProject)'!='true' AND '@(ReferenceFromRuntime)' != ''">
<ItemGroup>
<!-- transform to filename in order to intersect -->
2017-03-02 21:00:54 +03:00
<_referencePathFromRuntimeByFileName Include="@(_referencePathFromRuntime->'%(FileName)')" Condition="'%(_referencePathFromRuntime.Extension)' == '.dll'" >
2017-02-02 02:58:41 +03:00
<ReferencePath>%(Identity)</ReferencePath>
</_referencePathFromRuntimeByFileName>
<!-- intersect with ReferenceFromRuntime -->
<_filteredReferencePathFromRuntimeByFileName Include="@(_referencePathFromRuntimeByFileName)"
Condition="'@(_referencePathFromRuntimeByFileName)' == '@(ReferenceFromRuntime)' AND '%(Identity)' != ''" />
2017-03-01 23:53:25 +03:00
<_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="@(_referencePathFromRuntimeByFileName)"
Condition="'@(_referencePathFromRuntimeByFileName)' == '@(_remainingReferenceFromRuntimeWithNI)' AND '%(Identity)' != ''" />
<_missingReferenceFromRuntime Include="@(_remainingReferenceFromRuntimeWithNI)" Exclude="@(_filteredReferencePathFromRuntimeByFileName)" />
2017-02-02 02:58:41 +03:00
<!-- transform back to path -->
<ReferencePath Include="@(_filteredReferencePathFromRuntimeByFileName->'%(ReferencePath)')" />
</ItemGroup>
<Error Condition="'@(_missingReferenceFromRuntime)' != ''"
2017-03-01 23:53:25 +03:00
Text="Could not resolve ReferenceFromRuntime item(s) '%(_missingReferenceFromRuntime.OriginalReferenceFromRuntime)' from '$(RuntimeProjectFile)'." />
2017-02-02 02:58:41 +03:00
</Target>
</Project>