forked from NethermindEth/nethermind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExternalProjectPackages.targets
36 lines (29 loc) · 2.01 KB
/
ExternalProjectPackages.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<Project>
<PropertyGroup>
<ExternalProjectDirectory>$(ExternalProjectDirectory)</ExternalProjectDirectory>
<ExternalProjectName>$(ExternalProjectName)</ExternalProjectName>
<ExternalProjectReference>$(ExternalProjectReference)</ExternalProjectReference>
</PropertyGroup>
<Target Name="ConsumeExternalProjectPackages" BeforeTargets="CollectPackageReferences">
<Error Text="The property ExternalProjectDirectory was not set" Condition="'$(ExternalProjectDirectory)' == ''" />
<Error Text="The property ExternalProjectDirectory does not end with "/"" Condition="!$(ExternalProjectDirectory.EndsWith('/'))" />
<Error Text="The property ExternalProjectName was not set" Condition="'$(ExternalProjectName)' == ''" />
<PropertyGroup>
<_ExternalProjectReference Condition="'$(ExternalProjectReference)' == ''">$(ExternalProjectDirectory)$(ExternalProjectName).csproj</_ExternalProjectReference>
</PropertyGroup>
<PropertyGroup>
<ExternalProjectPackages>$(MSBuildProjectDirectory)/obj/$(ExternalProjectName).$(MSBuildThisFileName).props</ExternalProjectPackages>
</PropertyGroup>
<MSBuild Projects="$(_ExternalProjectReference)" Targets="Restore" />
<Exec Command="dotnet script $(MSBuildThisFileDirectory)../scripts/ImportableExternalPackages/main.csx -- "$(ExternalProjectDirectory)obj/project.assets.json" "$(ExternalProjectPackages)"" />
<!-- As we can not import dynamically the .props with the packages inside we use this as workaround -->
<MSBuild Projects="$(MSBuildThisFileDirectory)OutputImportedPackages.targets" Targets="OutputPackageReferences" Properties="ImportProject=$(ExternalProjectPackages)">
<Output TaskParameter="TargetOutputs" ItemName="_ExternalProjectPackageReferences" />
</MSBuild>
<ItemGroup>
<PackageReference Include="@(_ExternalProjectPackageReferences)" />
</ItemGroup>
<!-- For debug purpose -->
<!-- <Message Importance="High" Text="%(PackageReference.Identity)" /> -->
</Target>
</Project>