forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binplace.targets
180 lines (153 loc) · 10.1 KB
/
binplace.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" InitialTargets="CheckForBuildTools" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' AND '$(IsReferenceAssembly)' != 'true' AND '$(BinPlaceRef)' != 'true' AND '$(IsTestProject)' != 'true'">true</IsRuntimeAssembly>
<!-- Try to determine if this is a simple library without a ref project.
https://github.com/dotnet/corefx/issues/14291 is tracking cleaning this up -->
<IsRuntimeAndReferenceAssembly Condition="'$(IsRuntimeAndReferenceAssembly)' == '' and '$(IsRuntimeAssembly)' == 'true' and Exists('$(SourceDir)/$(AssemblyName)') and !Exists('$(SourceDir)/$(AssemblyName)/ref') and !$(AssemblyName.StartsWith('System.Private'))">true</IsRuntimeAndReferenceAssembly>
<IsNETCoreAppRef Condition="'$(IsNETCoreAppRef)' == ''">$(IsNETCoreApp)</IsNETCoreAppRef>
<IsUAPRef Condition="'$(IsUAPRef)' == ''">$(IsUAP)</IsUAPRef>
<BuildingDesktopFacade Condition="'$(IsDesktopFacade)' == 'true' And ('$(TargetGroup)' == 'netfx' Or $(TargetGroup.StartsWith('net4')))" >true</BuildingDesktopFacade>
<!-- if building desktop facade, we don't bin place the refs -->
<BinPlaceRef Condition="'$(BinPlaceRef)' == '' And '$(BuildingDesktopFacade)' != 'true' And ('$(IsReferenceAssembly)' == 'true' OR '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRef>
<BinPlaceRuntime Condition="'$(BinPlaceRuntime)' == '' And ('$(IsRuntimeAssembly)' == 'true' OR '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRuntime>
<!-- if building desktop facade and bin placing the runtime, then we need to bin place the refs too -->
<BinPlaceRef Condition="'$(BuildingDesktopFacade)' == 'true' And '$(BinPlaceRuntime)' == 'true'">true</BinPlaceRef>
<BinPlaceUseHardlinksIfPossible Condition="'$(BinPlaceUseHardlinksIfPossible)' == ''">true</BinPlaceUseHardlinksIfPossible>
</PropertyGroup>
<ItemGroup Condition="'@(BinPlaceConfiguration)' == ''">
<!-- binplace to directories for the target vertical -->
<BinPlaceConfiguration Include="$(BuildConfiguration)">
<RefPath>$(BuildConfigurationRefPath)</RefPath>
<RuntimePath>$(RuntimePath)</RuntimePath>
</BinPlaceConfiguration>
<!-- binplace to directories for packages -->
<BinPlaceConfiguration Condition="'$(IsNETCoreApp)' == 'true' AND '$(BuildingNETCoreAppVertical)' == 'true'" Include="netcoreapp-$(_bc_OSGroup)">
<PackageFileRefPath Condition="'$(IsNETCoreAppRef)' == 'true'">$(NETCoreAppPackageRefPath)</PackageFileRefPath>
<PackageFileRuntimePath>$(NETCoreAppPackageRuntimePath)</PackageFileRuntimePath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(IsUAP)' == 'true' AND '$(BuildingUAPVertical)' == 'true'" Include="uap-$(_bc_OSGroup)">
<PackageFileRefPath Condition="'$(IsUAPRef)'=='true'">$(UAPPackageRefPath)</PackageFileRefPath>
<PackageFileRuntimePath>$(UAPPackageRuntimePath)</PackageFileRuntimePath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(IsUAP)' == 'true' AND '$(BuildingUAPAOTVertical)' == 'true'" Include="uapaot-$(_bc_OSGroup)">
<PackageFileRefPath Condition="'$(IsUAPRef)'=='true'">$(UAPPackageRefPath)</PackageFileRefPath>
<PackageFileRuntimePath>$(UAPAOTPackageRuntimePath)</PackageFileRuntimePath>
</BinPlaceConfiguration>
<!-- Setup the shared framework directory for testing -->
<BinPlaceConfiguration Condition="'$(BinPlaceTestSharedFramework)' == 'true'" Include="netcoreapp-$(_bc_OSGroup)">
<RuntimePath>$(NETCoreAppTestSharedFrameworkPath)</RuntimePath>
</BinPlaceConfiguration>
<!-- Setup the ILCInputFolder directory for testing uapaot -->
<BinPlaceConfiguration Condition="'$(BinPlaceILCInputFolder)' == 'true'" Include="uapaot-$(_bc_OSGroup)">
<RuntimePath>$(ILCFXInputFolder)</RuntimePath>
</BinPlaceConfiguration>
<!-- binplace targeting packs which may be different from BuildConfiguration -->
<BinPlaceConfiguration Include="netstandard">
<RefPath>$(RefRootPath)netstandard/</RefPath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(BuildAllConfigurations)' == 'true'"
Include="netcoreapp">
<RefPath>$(RefRootPath)netcoreapp/</RefPath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(BuildAllConfigurations)' == 'true'"
Include="uap">
<RefPath>$(RefRootPath)uap/</RefPath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(BuildAllConfigurations)' == 'true'"
Include="netfx">
<RefPath>$(RefRootPath)netfx/</RefPath>
</BinPlaceConfiguration>
</ItemGroup>
<Target Name="BinPlace"
DependsOnTargets="GetBinPlaceDirs;BinPlaceFiles;BinPlaceProps"
AfterTargets="CopyFilesToOutputDirectory"
Condition="'$(BinPlaceRef)' == 'true' OR '$(BinPlaceRuntime)' == 'true'" />
<Target Name="BinPlaceFiles"
Condition="'@(BinPlaceDir)' != ''"
DependsOnTargets="GetBinPlaceItems" >
<Message Importance="low" Text="BinPlaceDir: @(BinPlaceDir)" />
<Copy SourceFiles="@(BinPlaceItem)"
DestinationFolder="%(BinPlaceDir.Identity)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(BinPlaceUseHardlinksIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
</Target>
<UsingTask TaskName="SaveItems" AssemblyFile="$(CoreFxToolsTaskDir)CoreFx.Tools.dll"/>
<Target Name="BinPlaceProps"
Condition="'@(PackageFileDir)' != ''"
DependsOnTargets="GetBinPlaceItems" >
<PropertyGroup>
<_propsFilename>$(TargetName)</_propsFilename>
<_propsFilename Condition="'$(_propsFilename)' == ''">$(MSBuildProjectName)</_propsFilename>
<_projectDirLength>$(ProjectDir.Length)</_projectDirLength>
</PropertyGroup>
<ItemGroup>
<_itemsToSave Include="@(BinPlaceItem)">
<!-- intentionally empty: to be set by pkgproj -->
<TargetPath></TargetPath>
</_itemsToSave>
<!-- Include source files. -->
<_itemsToSave Condition="'@(Compile)' != ''" Include="@(Compile->'%(FullPath)')">
<TargetPath>src</TargetPath>
<TargetPath Condition="$([System.String]::Copy('%(FullPath)').StartsWith('$(ProjectDir)'))">src/$([System.String]::Copy('%(FullPath)').Substring($(_projectDirLength)).Replace('\', '/'))</TargetPath>
<IsSourceCodeFile>true</IsSourceCodeFile>
</_itemsToSave>
</ItemGroup>
<Message Importance="low" Text="PackageFileDir: @(PackageFileDir)" />
<SaveItems ItemName="FileToPackage"
Items="@(_itemsToSave)"
Files="@(PackageFileDir->'%(Identity)\$(_propsFilename).props')" />
</Target>
<Target Name="GetBinPlaceItems" DependsOnTargets="GetCopyToOutputDirectoryItems">
<ItemGroup>
<BinPlaceItem Condition="Exists('$(TargetPath)')" Include="$(TargetPath)" />
<BinPlaceItem Condition="Exists('$(TargetDir)$(TargetName).pdb')" Include="$(TargetDir)$(TargetName).pdb" />
<BinPlaceItem Condition="'$(BinPlaceReferenceCopyLocalPaths)' != 'false'" Include="@(ReferenceCopyLocalPaths)" />
<BinPlaceItem Condition="'$(BinPlaceCopyToOutputDirectoryItems)' != 'false'" Include="@(AllItemsFullPathWithTargetPath)" />
</ItemGroup>
</Target>
<Target Name="GetBinPlaceDirs" DependsOnTargets="GetBuildConfigurations">
<!-- find which, if any, build configuration of this project is best
for each binplace configuration -->
<FindBestConfigurations Properties="@(Property)"
PropertyValues="@(PropertyValue)"
SupportedConfigurations="$(_AllBuildConfigurations)"
Configurations="@(BinPlaceConfiguration)">
<Output TaskParameter="BestConfigurations" ItemName="_bestBinlaceConfigurations" />
</FindBestConfigurations>
<ItemGroup>
<_currentBinPlaceConfigurations Include="@(_bestBinlaceConfigurations)" Condition="'%(Identity)' == '$(Configuration)' OR '%(Identity)-$(ConfigurationGroup)' == '$(Configuration)'" />
<BinPlaceDir Condition="'$(BinPlaceRuntime)' == 'true'" Include="%(_currentBinPlaceConfigurations.RuntimePath)" />
<BinPlaceDir Condition="'$(BinPlaceRef)' == 'true'" Include="%(_currentBinPlaceConfigurations.RefPath)" />
<PackageFileDir Condition="'$(BinPlaceRuntime)' == 'true'" Include="%(_currentBinPlaceConfigurations.PackageFileRuntimePath)" />
<PackageFileDir Condition="'$(BinPlaceRef)' == 'true'" Include="%(_currentBinPlaceConfigurations.PackageFileRefPath)" />
</ItemGroup>
</Target>
<ItemGroup>
<AdditionalCleanDirectories Include="$(BinDir)netcoreapp" />
</ItemGroup>
<!-- Incremental clean only cleans paths under Intermediate or OutDir, handle additional paths -->
<Target Name="_CleanGetCurrentAdditionalFileWrites" BeforeTargets="_CleanGetCurrentAndPriorFileWrites">
<!-- find files under paths we care about and add them to _CleanCurrentFileWrites to ensure they are written to the file list -->
<FindUnderPath Path="%(AdditionalCleanDirectories.Identity)" Files="@(FileWrites)" UpdateToAbsolutePaths="true">
<Output TaskParameter="InPath" ItemName="_CleanCurrentFileWrites" />
</FindUnderPath>
</Target>
<Target Name="IncrementalCleanAdditionalDirectories" BeforeTargets="IncrementalClean">
<ItemGroup>
<_CleanOrphanAdditionalFileWrites Include="@(_CleanPriorFileWrites)" Exclude="@(_CleanCurrentFileWrites)" />
</ItemGroup>
<FindUnderPath Path="%(AdditionalCleanDirectories.Identity)" Files="@(_CleanOrphanAdditionalFileWrites)">
<Output TaskParameter="InPath" ItemName="_CleanOrphanFileWritesInAdditionalDirectories" />
</FindUnderPath>
<!-- Delete the orphaned files. IncrementalClean will remove these from the file list -->
<Delete Files="@(_CleanOrphanFileWritesInAdditionalDirectories)" TreatErrorsAsWarnings="true">
<Output TaskParameter="DeletedFiles" ItemName="_CleanOrphanFilesDeleted" />
</Delete>
</Target>
</Project>