-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
packageTest.targets
158 lines (138 loc) · 8.49 KB
/
packageTest.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
<Project>
<PropertyGroup>
<_targetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' != ''">$(TargetFrameworkIdentifier.Substring(1).ToLower())</_targetFrameworkIdentifier>
<!-- Make sure the SDK raises the runtime items so that they are passed to conflict resolution -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<CopyLocalRuntimeTargetAssets>true</CopyLocalRuntimeTargetAssets>
<!-- Suppress any SYSLIB9000 errors, as in these cases restore/build would succeed, the failure would be at run-time -->
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>
<ItemGroup>
<!-- Required for VerifyClosure and VerifyTypes tasks. -->
<PackageReference Include="Microsoft.DotNet.PackageTesting" Version="$(MicrosoftDotNetPackageTestingVersion)" />
</ItemGroup>
<!-- Import framework settings. -->
<Import Project="frameworkSettings\$(_targetFrameworkIdentifier)\*.targets"
Condition="'$(_targetFrameworkIdentifier)' != ''" />
<Import Project="frameworkSettings\$(TargetFramework)\*.targets" />
<!-- Import package settings. -->
<Import Project="packageSettings\$(TestPackageId)\*.targets" />
<Import Project="packageSettings\$(TestPackageId)\$(_targetFrameworkIdentifier)\*.targets"
Condition="'$(_targetFrameworkIdentifier)' != ''" />
<Import Project="packageSettings\$(TestPackageId)\$(TargetFramework)\*.targets"
Condition="'$(TargetFramework)' != ''" />
<ItemGroup>
<!-- Type duplicated: https://github.com/dotnet/runtime/issues/33998 -->
<IgnoredTypes Include="Microsoft.Extensions.Logging.LoggingBuilderExtensions" />
<!-- Type duplicated: https://github.com/dotnet/runtime/issues/34420 -->
<IgnoredTypes Include="System.Collections.Generic.CollectionExtensions" />
</ItemGroup>
<Target Name="LogBeginTest"
Condition="'$(TargetFramework)' != ''">
<Message Importance="High" Text="Testing $(TestPackageID) TFM=$(TargetFramework)" />
</Target>
<Target Name="VerifyReferenceClosure"
DependsOnTargets="ResolveReferences"
Condition="'$(ShouldVerifyClosure)' == 'true'">
<ItemGroup>
<_refClosureFileNames Include="@(ReferencePath->'%(FileName)')">
<Original>%(Identity)</Original>
</_refClosureFileNames>
<_refClosureFileNamesFiltered Include="@(_refClosureFileNames)" Exclude="@(ExcludeFromClosure);@(ExcludeFromClosure->'%(Identity).ni')"/>
<_refClosureFileFiltered Include="@(_refClosureFileNamesFiltered->'%(Original)')"/>
</ItemGroup>
<VerifyClosure Condition="'@(_refClosureFileFiltered)' != ''"
Sources="@(_refClosureFileFiltered)"
IgnoredReferences="@(IgnoredReference)" />
</Target>
<Target Name="VerifyReferenceTypes"
DependsOnTargets="ResolveReferences"
Condition="'$(ShouldVerifyTypes)' == 'true'">
<ItemGroup>
<_refTypesFileNames Include="@(ReferencePath->'%(FileName)')">
<Original>%(Identity)</Original>
</_refTypesFileNames>
<_refTypesFileNamesFiltered Include="@(_refTypesFileNames)" Exclude="@(ExcludeFromTypes);@(ExcludeFromTypes->'%(Identity).ni')"/>
<_refTypesFileFiltered Include="@(_refTypesFileNamesFiltered->'%(Original)')"/>
</ItemGroup>
<VerifyTypes Condition="'@(_refTypesFileFiltered)' != ''"
Sources="@(_refTypesFileFiltered)"
IgnoredTypes="@(IgnoredTypes)" />
</Target>
<Target Name="PrepareForRuntimeTesting" DependsOnTargets="ResolveReferences">
<ItemGroup>
<ReferenceLibToTest Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)' == '$(TestPackageId)'" />
<RuntimeLibToTest Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == '$(TestPackageId)'" />
<!-- Don't verify RID specific libs that aren't compatible on .NETFramework, i.e. Unix. -->
<RuntimeLibToTest Remove="@(RuntimeLibToTest)" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and
'%(RuntimeLibToTest.RuntimeIdentifier)' != '' and
'%(RuntimeLibToTest.RuntimeIdentifier)' != 'win' and
!$([System.String]::Copy('%(RuntimeLibToTest.RuntimeIdentifier)').StartsWith('win-'))" />
<RuntimeLibToTest Condition="'%(RuntimeLibToTest.RuntimeIdentifier)' == ''" RuntimeIdentifier="none" />
</ItemGroup>
<ItemGroup>
<RuntimeLibToTestDependency Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)' != '$(TestPackageId)'" />
<!-- Some dependent packages may be excluded from compile, consider these as candidates as well.-->
<ReferenceCopyLocalPaths Original="%(Identity)" />
<_referenceCopyLocalPathsPackages Include="@(ReferenceCopyLocalPaths->'%(NuGetPackageId)')"
Condition="'%(ReferenceCopyLocalPaths.RuntimeIdentifier)' == ''"
Exclude="@(ReferencePath->'%(NuGetPackageId)');$(TestPackageId)" />
<RuntimeLibToTestDependency Include="@(_referenceCopyLocalPathsPackages->'%(Original)')" />
</ItemGroup>
<Error Condition="'@(RuntimeLibToTest)' == '' AND '@(ReferenceLibToTest)' != ''" Text="Could not locate any runtime items from Package $(TestPackageID)" />
<Message Condition="'@(RuntimeLibToTest)' != ''" Importance="High" Text="Testing $(TestPackageID) runtime on TFM=$(TargetFramework) RIDs=@(RuntimeLibToTest->'%(RuntimeIdentifier)'->Distinct())" />
</Target>
<Target Name="VerifyRuntimeClosure"
Inputs="%(RuntimeLibToTest.RuntimeIdentifier)"
Outputs="unused"
DependsOnTargets="PrepareForRuntimeTesting"
Condition="'$(ShouldVerifyClosure)' == 'true' and '$(SkipVerifyClosureForRuntime)' != 'true' and '$(SkipVerifyRuntime)' != 'true'">
<Message Importance="High" Text="Testing closure for $(TestPackageID) TFM=$(TargetFramework) RID=%(RuntimeLibToTest.RuntimeIdentifier)" />
<ItemGroup>
<_runClosureFileNames Include="@(RuntimeLibToTestDependency->'%(FileName)');@(RuntimeLibToTest->'%(FileName)')">
<Original>%(Identity)</Original>
</_runClosureFileNames>
<_runClosureFileNamesFiltered Include="@(_runClosureFileNames)" Exclude="@(ExcludeFromClosure);@(ExcludeFromClosure->'%(Identity).ni')"/>
<_runClosureFileFiltered Include="@(_runClosureFileNamesFiltered->'%(Original)')"/>
</ItemGroup>
<VerifyClosure Condition="'@(_runClosureFileFiltered)' != ''"
Sources="@(_runClosureFileFiltered)"
IgnoredReferences="@(IgnoredReference)" />
</Target>
<Target Name="VerifyRuntimeTypes"
Inputs="%(RuntimeLibToTest.RuntimeIdentifier)"
Outputs="unused"
DependsOnTargets="PrepareForRuntimeTesting"
Condition="'$(ShouldVerifyTypes)' == 'true' and '$(SkipVerifyRuntime)' != 'true'">
<Message Importance="High" Text="Testing for duplicate types for $(TestPackageID) TFM=$(TargetFramework) RID=%(RuntimeLibToTest.RuntimeIdentifier)" />
<ItemGroup>
<_runTypesFileNames Include="@(RuntimeLibToTestDependency->'%(FileName)');@(RuntimeLibToTest->'%(FileName)')">
<Original>%(Identity)</Original>
</_runTypesFileNames>
<_runTypesFileNamesFiltered Include="@(_runTypesFileNames)" Exclude="@(ExcludeFromTypes);@(ExcludeFromTypes->'%(Identity).ni')"/>
<_runTypesFileFiltered Include="@(_runTypesFileNamesFiltered->'%(Original)')"/>
</ItemGroup>
<VerifyTypes Condition="'@(_runTypesFileFiltered)' != ''"
Sources="@(_runTypesFileFiltered)"
IgnoredTypes="@(IgnoredTypes)" />
</Target>
<Target Name="VerifyNotDependsOnNetStandard"
DependsOnTargets="ResolveReferences"
Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and
'$(DisableVerifyNotDependsOnNetStandardTest)' != 'true'">
<Error Condition="'$(DependsOnNetStandard)' == 'true'" Text="Package $(TestPackageId) requires netstandard shims when targeting $(TargetFramework)" />
</Target>
<PropertyGroup>
<TestDependsOn>
LogBeginTest;
VerifyNotDependsOnNetStandard;
VerifyReferenceClosure;
VerifyReferenceTypes;
VerifyRuntimeClosure;
VerifyRuntimeTypes;
</TestDependsOn>
<InnerTargets>Test</InnerTargets>
</PropertyGroup>
<!-- Runs all tests scenarios for this project -->
<Target Name="Test" DependsOnTargets="$(TestDependsOn)" />
</Project>