-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
SdkReferences.targets
204 lines (181 loc) · 9.76 KB
/
SdkReferences.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<Project>
<ItemGroup>
<PackageReference Include="$(MicrosoftPrivateWinformsPackage)"
Version="$(MicrosoftPrivateWinformsVersion)"
ExcludeAssets="All"
GeneratePathProperty="True"
Condition="'$(MSBuildProjectExtension)'!='.vcxproj'
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And ('$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.1' Or '$(TargetFrameworkVersion)' == 'v5.0')
And '$(NoAutoMicrosoftPrivateWinformsReference)'!='true'"/>
<!--
When @(NetCoreReference) is non-empty, exclude all assets (ExcludeAssets = All) and re-add them in
ResolveMicrosoftNetCoreAppReferences target
-->
<PackageReference Update="Microsoft.NETCore.App"
GeneratePathProperty="true"
ExcludeAssets="All"
Condition="'@(NetCoreReference)'!='' And '$(DoNotLimitMicrosoftNetCoreReferences)'!='true' And '$(MSBuildProjectExtension)'!='.vcxproj' And '$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<PackageReference Update="Microsoft.NETCore.App"
GeneratePathProperty="true"
Condition="('@(NetCoreReference)'=='' Or '$(DoNotLimitMicrosoftNetCoreReferences)' == 'true') And '$(MSBuildProjectExtension)'!='.vcxproj' And '$(DisableImplicitFrameworkReferences)' != 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
</ItemGroup>
<Target Name="GeneratePathPropertyforMicrosoftWindowsDesktopApp"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<PackageReference Update="Microsoft.WindowsDesktop.App"
GeneratePathProperty="true" />
</ItemGroup>
</Target>
<PropertyGroup>
<ResolveAssemblyReferencesDependsOn>
ResolveMicrosoftDotNetWpfGitHubReferences;
ResolveMicrosoftDotNetWpfDncEngReferencesForCpp;
ResolveWinFormsReferences;
$(ResolveAssemblyReferencesDependsOn)
</ResolveAssemblyReferencesDependsOn>
</PropertyGroup>
<Target
Name="LimitNetCoreAppReferences"
AfterTargets="ResolveTargetingPackAssets;ResolveTargetingPacks"
Returns="@(Reference)"
Condition="'@(NetCoreReference)' != '' And '@(Reference)' != ''">
<!--
Example
<NetCoreReference Include="Microsoft.CSharp" />
-->
<!--
Save Microsoft.NETCore.App.Ref assemblies, and remove those from @(Reference)
-->
<ItemGroup>
<_netCoreAppSdkReference Remove="@(_netCoreAppSdkReference)" />
<_netCoreAppSdkReference Include="@(Reference)"
Condition="'%(Reference.NuGetPackageId)'=='Microsoft.NETCore.App.Ref'">
<OriginalPath>%(Reference.Identity)</OriginalPath>
</_netCoreAppSdkReference>
<Reference Remove="@(_netCoreAppSdkReference)" />
</ItemGroup>
<ItemGroup>
<_netCoreAppReferences Remove="@(_netCoreAppReferences)" />
</ItemGroup>
<FilterItem1ByItem2 Item1="@(_netCoreAppSdkReference->'%(FileName)')"
Item2="@(NetCoreReference)"
Metadata2="Identity"
PreserveItem1Metadata="true">
<Output ItemName="_netCoreAppReferences" TaskParameter="Result" />
</FilterItem1ByItem2>
<ItemGroup>
<Reference Include="@(_netCoreAppReferences->'%(OriginalPath)')" />
</ItemGroup>
</Target>
<Target Name="LimitWindowsDesktopAppReferences"
AfterTargets="ResolveTargetingPacks;ResolveTargetingPackAsssets"
Returns="@(Reference)"
Condition="'@(WindowsDesktopReference)'!='' and '@(Reference)' != ''">
<!--
Example
<WindowsDesktopReference Include="PresentationCore" />
-->
<!--
Save Microsoft.WindowsDesktop.App.Ref assemblies, and remove those from @(Reference)
-->
<ItemGroup>
<_windowsDesktopAppSdkReference Remove="@(_windowsDesktopAppSdkReference)" />
<_windowsDesktopAppSdkReference Include="@(Reference)"
Condition="'%(Reference.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref'">
<OriginalPath>%(Reference.Identity)</OriginalPath>
</_windowsDesktopAppSdkReference>
<Reference Remove="@(_windowsDesktopAppSdkReference)" />
</ItemGroup>
<ItemGroup>
<_windowsDesktopAppReferences Remove="@(_windowsDesktopAppReferences)" />
</ItemGroup>
<FilterItem1ByItem2 Item1="@(_windowsDesktopAppSdkReference->'%(FileName)')"
Item2="@(WindowsDesktopReference)"
Metadata2="Identity"
PreserveItem1Metadata="true">
<Output ItemName="_windowsDesktopAppReferences" TaskParameter="Result" />
</FilterItem1ByItem2>
<ItemGroup>
<Reference Include="@(_windowsDesktopAppReferences->'%(OriginalPath)')" />
</ItemGroup>
</Target>
<Target
Name="ResolveMicrosoftDotNetWpfGitHubReferences"
Returns="@(ReferencePath)"
Condition="'@(MicrosoftDotNetWpfGitHubReference)'!=''
And '$(MSBuildProjectExtension)' != '.vcxproj'
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And ('$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.1' Or '$(TargetFrameworkVersion)' == 'v5.0')
and '$(DoNotLimitMicrosoftDotNetWpfGitHubReferences)'!='true'">
<!--
In your project, Add a references to WPF GitHub transport package like this:
<ItemGroup>
<MicrosoftDotNetWpfGitHubReference Include="System.Xaml" />
</ItemGroup>
It will get translated into something like this:
<ItemGroup>
<Reference Include="C:\Users\username\.nuget\packages\microsoft.dotnet.wpf.github\4.8.0-preview4.19174.2\ref\netcoreapp3.0\System.Xaml.dll" />
</ItemGroup>
-->
<PropertyGroup>
<!-- Since WPF reference assemblies do not carry internals, we need to directly reference the RID-specific lib assemblies from dotnet_wpf_int builds. -->
<WpfGitHubRidSpecificPackagePath Condition="'$(WpfRuntimeIdentifier)'=='win-x86' And '$(Configuration)' != 'Debug'">$(Pkgruntime_win-x86_Microsoft_DotNet_Wpf_GitHub)</WpfGitHubRidSpecificPackagePath>
<WpfGitHubRidSpecificPackagePath Condition="'$(WpfRuntimeIdentifier)'=='win-x86' And '$(Configuration)' == 'Debug'">$(Pkgruntime_win-x86_Microsoft_DotNet_Wpf_GitHub_Debug)</WpfGitHubRidSpecificPackagePath>
<WpfGitHubRidSpecificPackagePath Condition="'$(WpfRuntimeIdentifier)'=='win-x64' And '$(Configuration)' != 'Debug'">$(Pkgruntime_win-x64_Microsoft_DotNet_Wpf_GitHub)</WpfGitHubRidSpecificPackagePath>
<WpfGitHubRidSpecificPackagePath Condition="'$(WpfRuntimeIdentifier)'=='win-x64' And '$(Configuration)' == 'Debug'">$(Pkgruntime_win-x64_Microsoft_DotNet_Wpf_GitHub_Debug)</WpfGitHubRidSpecificPackagePath>
</PropertyGroup>
<ItemGroup>
<Reference Include="$(WpfGitHubRidSpecificPackagePath)\lib\$(TargetFramework)\%(MicrosoftDotNetWpfGitHubReference.Identity).dll"
Condition="Exists('$(WpfGitHubRidSpecificPackagePath)\lib\$(TargetFramework)\%(MicrosoftDotNetWpfGitHubReference.Identity).dll')">
<NuGetPackageId>runtime.$(WpfRuntimeIdentifier).$(GitHubTransportPackageName)</NuGetPackageId>
</Reference>
</ItemGroup>
</Target>
<Target
Name="ResolveMicrosoftDotNetWpfDncEngReferencesForCpp"
Returns="@(Link)"
Condition="'@(MicrosoftDotNetWpfGitHubReference)'!=''
And '$(MSBuildProjectExtension)' == '.vcxproj'
and '$(DoNotLimitMicrosoftDotNetWpfGitHubReferences)'!='true'">
<!--
Normally, we would use lib files from RID-specific Microsoft.DotNet.Wpf.DncEng package directly. Since this package
was most likley not restored prior to the start of the build, it had to be restored from with the CppHelper target, and the libs in this package
are now enumerated within @(NuGetReferencesForCpp) item.
-->
<!--
Select items from with @(NuGetReferencesForCpp) (which is a proxy for Microsoft.DotNet.Wpf.DncEng's native libs)
that were requested in MicrosoftDotNetWpfGitHubReference
-->
<FilterItem1ByItem2 Item1="@(NuGetReferencesForCpp->'%(FileName)')"
Item2="@(MicrosoftDotNetWpfGitHubReference)"
Metadata2="Identity"
PreserveItem1Metadata="true">
<Output ItemName="_nugetLibReferencesForCpp" TaskParameter="Result" />
</FilterItem1ByItem2>
<ItemGroup>
<Link Include="@(_nugetLibReferencesForCpp->'%(FilePath)')" />
</ItemGroup>
</Target>
<!--
In your project, Add a references to WinForms transport package like this:
<ItemGroup>
<MicrosoftPrivateWinFormsReference Include="Accessbility" />
</ItemGroup>
It will get translated into something like this:
<ItemGroup>
<Reference Include="C:\Users\username\.nuget\packages\microsoft.private.winforms\4.8.0-preview4.19170.4\lib\netcoreapp3.0\Accessibility.dll" />
</ItemGroup>
-->
<Target Name="ResolveWinFormsReferences"
Condition="'@(MicrosoftPrivateWinFormsReference)'!=''
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And ('$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.1' Or '$(TargetFrameworkVersion)' == 'v5.0') ">
<ItemGroup>
<Reference Include="$(PkgMicrosoft_Private_Winforms)\ref\$(TargetFramework)\%(MicrosoftPrivateWinFormsReference.Identity).dll"
Condition="Exists('$(PkgMicrosoft_Private_Winforms)\ref\$(TargetFramework)\%(MicrosoftPrivateWinFormsReference.Identity).dll')">
<NuGetPackageId>Microsoft.Private.Winforms</NuGetPackageId>
</Reference>
</ItemGroup>
</Target>
</Project>