-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
157 lines (114 loc) · 5.86 KB
/
Directory.Build.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<Project>
<PropertyGroup Condition=" '$(ProjectType)' == 'SdkProject' ">
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<PackageType>MSBuildSdk</PackageType>
<PackageTags>MSBuild MSBuildSdk</PackageTags>
<IncludeSymbols>false</IncludeSymbols>
<TargetsForTfmSpecificContentInPackage>
$(TargetsForTfmSpecificContentInPackage);
_AddTfmBuildItemsToPack;
</TargetsForTfmSpecificContentInPackage>
<BeforePack>
$(BeforePack);
_AddSdkItemsToPack;
</BeforePack>
</PropertyGroup>
<ItemGroup
Condition=" '$(ProjectType)' == 'SdkProject' ">
<AvailableItemName Include="SdkItem" />
<AvailableItemName Include="BuildItem" />
</ItemGroup>
<Target Name="_AddSdkItemsToPack" DependsOnTargets="_BuildSdkItems">
<ItemGroup>
<_PackageFiles Include="%(SdkItem.IntermediateOutputPath)"
PackagePath="%(SdkItem.PackagePath)" BuildAction="SdkItem" />
</ItemGroup>
</Target>
<Target Name="_AddTfmBuildItemsToPack" DependsOnTargets="_BuildBuildItems;_CreateEmptyTargetFile">
<ItemGroup>
<TfmSpecificPackageFile Include="%(BuildItem.IntermediateOutputPath)"
PackagePath="%(BuildItem.PackagePath)" BuildAction="BuildItem" />
<TfmSpecificPackageFile Include="$(IntermediateOutputPath)_._"
PackagePath="lib/$(TargetFramework)/_._" BuildAction="None" />
</ItemGroup>
</Target>
<Target Name="_CalculateSdkItemsPaths" Condition="'@(SdkItem->Count())' > 0">
<PropertyGroup>
<_SdkItemsDir>$([System.IO.Path]::GetFullPath('Sdk\'))</_SdkItemsDir>
<_SdkItemsIntermediateOutputPath>$(IntermediateOutputPath)sdk\</_SdkItemsIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<_SdkItem Include="@(SdkItem)">
<RelativePath Condition="'%(SdkItem.RelativePath)' == ''">$([MSBuild]::MakeRelative($(_SdkItemsDir), '%(SdkItem.FullPath)'))</RelativePath>
<IntermediateOutputPath Condition="'%(SdkItem.IntermediateOutputPath)' == ''">$(_SdkItemsIntermediateOutputPath)%(_SdkItem.RelativePath)</IntermediateOutputPath>
</_SdkItem>
</ItemGroup>
<Error
Text="The file '%(_SdkItem.Identity)' is located outside the Sdk folder '$(_SdkItemsDir)' and does not have a PackagePath set"
Code="YOLOSDK0001"
Condition="$([System.String]::new('%(_SdkItem.RelativePath)').StartsWith('..')) And '%(_SdkItem.PackagePath)' == ''" />
<ItemGroup>
<SdkItem Remove="@(SdkItem)" />
<SdkItem Include="@(_SdkItem)">
<PackagePath Condition="'%(_SdkItem.PackagePath)' == ''">Sdk\%(_SdkItem.RelativePath)</PackagePath>
</SdkItem>
</ItemGroup>
</Target>
<Target Name="_CalculateBuildItemsPaths" Condition="'@(BuildItem->Count())' > 0">
<PropertyGroup>
<_BuildItemsDir>$([System.IO.Path]::GetFullPath('Build\'))</_BuildItemsDir>
<_BuildItemsIntermediateOutputPath>$(IntermediateOutputPath)build\</_BuildItemsIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<_BuildItem Include="@(BuildItem)">
<RelativePath Condition="'%(BuildItem.RelativePath)' == ''">$([MSBuild]::MakeRelative($(_BuildItemsDir), '%(BuildItem.FullPath)'))</RelativePath>
<IntermediateOutputPath Condition="'%(BuildItem.IntermediateOutputPath)' == ''">$(_BuildItemsIntermediateOutputPath)%(_BuildItem.RelativePath)</IntermediateOutputPath>
</_BuildItem>
</ItemGroup>
<Error
Text="The file '%(_BuildItem.Identity)' is located outside the Sdk folder '$(_BuildItemsDir)' and does not have a PackagePath set"
Code="YOLOSDK0002"
Condition="$([System.String]::new('%(_BuildItem.RelativePath)').StartsWith('..')) And '%(_BuildItem.PackagePath)' == ''" />
<ItemGroup>
<BuildItem Remove="@(BuildItem)" />
<BuildItem Include="@(_BuildItem)">
<PackagePath Condition="'%(_BuildItem.PackagePath)' == ''">build\$(TargetFramework)\%(_BuildItem.RelativePath)</PackagePath>
</BuildItem>
</ItemGroup>
</Target>
<Target Name="_BuildSdkItems" DependsOnTargets="_CalculateSdkItemsPaths" Inputs="@(SdkItem)"
Outputs="%(SdkItem.IntermediateOutputPath)">
<Error Text="The file '%(SdkItem.Identity)' could not be found" Code="YOLOSDK0002"
Condition="!Exists('%(SdkItem.FullPath)')" />
<PropertyGroup>
<FileContent>$([System.IO.File]::ReadAllText('%(SdkItem.FullPath)'))</FileContent>
<FileContent>$(FileContent.Replace('$$VERSION$$', '$(PackageVersion)'))</FileContent>
</PropertyGroup>
<WriteLinesToFile File="%(SdkItem.IntermediateOutputPath)" Lines="$(FileContent)"
Overwrite="true" />
<Message Importance="Low"
Text="Wrote sdk item '%(SdkItem.Identity)' to '%(SdkItem.IntermediateOutputPath)'" />
</Target>
<Target Name="_BuildBuildItems" DependsOnTargets="_CalculateBuildItemsPaths" Inputs="@(BuildItem)"
Outputs="%(BuildItem.IntermediateOutputPath)">
<Error Text="The file '%(BuildItem.Identity)' could not be found" Code="YOLOSDK0002"
Condition="!Exists('%(BuildItem.FullPath)')" />
<PropertyGroup>
<FileContent>$([System.IO.File]::ReadAllText('%(BuildItem.FullPath)'))</FileContent>
<FileContent>$(FileContent.Replace('$$VERSION$$', '$(PackageVersion)'))</FileContent>
</PropertyGroup>
<WriteLinesToFile File="%(BuildItem.IntermediateOutputPath)" Lines="$(FileContent)"
Overwrite="true" />
<Message Importance="Low"
Text="Wrote sdk item '%(BuildItem.Identity)' to '%(BuildItem.IntermediateOutputPath)'" />
</Target>
<Target Name="_CleanSdkItems" DependsOnTargets="_CalculateSdkItemsPaths" AfterTargets="Clean">
<Delete Files="@(SdkItem->'%(IntermediateOutputPath)')" />
</Target>
<Target Name="_CreateEmptyTargetFile" Outputs="$(IntermediateOutputPath)_._">
<WriteLinesToFile File="$(IntermediateOutputPath)_._" Lines="" Overwrite="true" />
</Target>
<!-- Dogfooding -->
<Import
Project="$(MSBuildThisFileDirectory)src\YoloDev.Sdk\Sdk\Sdk.targets" />
</Project>