blob: a27484cc6580f1f9e91ff5f683fe1b7297925917 (
plain)
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
|
<Project Sdk="Microsoft.Build.NoTargets">
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.PackageTesting" Version="$(MicrosoftDotNetPackageTestingVersion)" />
</ItemGroup>
<PropertyGroup>
<PackageNamePattern>[a-zA-z\.]*\.</PackageNamePattern>
<TestDir>$(ArtifactsBinDir)testPackages\</TestDir>
<TestProjectDir>$(TestDir)projects\</TestProjectDir>
<TestPackageDir>$(TestDir)cache\</TestPackageDir>
<TestProjectName>dirs.proj</TestProjectName>
<ProjectTemplate>project.csproj.template</ProjectTemplate>
</PropertyGroup>
<ItemGroup>
<PackagesToTest Condition="'$(PackagesToTest)' != ''" Include="$(PackagesToTest)" />
<!-- support override via commandline -->
<TargetFrameworksToInclude Condition="'$(TargetFrameworksToInclude)' != ''" Include="$(TargetFrameworksToInclude)" />
<SymbolsPackages Include="$(LibrariesAllConfigShippingPackagesDir)*.symbols.nupkg" />
<AllPackagesFilePath Include="$(LibrariesAllConfigShippingPackagesDir)*.nupkg" Exclude="@(SymbolsPackages)" Condition="Exists('$(LibrariesAllConfigShippingPackagesDir)')">
<PackageName>$([System.String]::new($([System.Text.RegularExpressions.Regex]::Match($([System.IO.Path]::GetFileNameWithoutExtension('%(Identity)')), $(PackageNamePattern)))).TrimEnd('.'))</PackageName>
<PackagePath>%(Identity)</PackagePath>
</AllPackagesFilePath>
<AllPackages Include="@(AllPackagesFilePath->'%(PackageName)')" />
<!-- runtime.native.System.IO.Ports requires all runtime legs to be built in order to test -->
<ExcludePackages Include="runtime.native.System.IO.Ports" />
<ExcludePackages Condition="'$(PackagesToTest)' != ''" Include="@(AllPackages)" Exclude="@(PackagesToTest)" />
<TestPackages Include="@(AllPackages)" Exclude="@(ExcludePackages)" />
<TestPackagesPath Include="@(TestPackages->'%(PackagePath)')" />
</ItemGroup>
<ItemGroup>
<!-- The main entry point file. -->
<TestSupportFile Include="build\$(TestProjectName)"
DestinationFolder="$(TestDir)" />
<!-- msbuild support files and the packaging VerifyClosure assembly. -->
<TestSupportFile Include="$(RepoRoot)global.json;
$(RepoRoot)NuGet.config;
$(RepositoryEngineeringDir)Versions.props;
$(RepositoryEngineeringDir)targetingpacks.targets;
$(LibrariesProjectRoot)NetCoreAppLibrary.props;
build\packageTest.targets;
build\Directory.Build.props;
build\Directory.Build.targets"
DestinationFolder="$(TestDir)" />
<!-- frameworksettings and packagesettings -->
<TestSupportFile Include="frameworkSettings\**\*"
DestinationFolder="$(TestDir)frameworkSettings\%(RecursiveDir)" />
<TestSupportFile Include="packageSettings\**\*"
DestinationFolder="$(TestDir)packageSettings\%(RecursiveDir)" />
</ItemGroup>
<Target Name="CreateTestDir"
Inputs="@(TestSupportFile)"
Outputs="@(TestSupportFile->'%(DestinationFolder)\%(FileName)%(Extension)')">
<MakeDir Directories="%(TestSupportFile.DestinationFolder)" />
<Copy SourceFiles="@(TestSupportFile)" DestinationFolder="%(TestSupportFile.DestinationFolder)" />
</Target>
<Target Name="GetSupportedPackages">
<!-- Adding NetCoreAppCurrent to the supported test frameworks list to avoid a test gap when
the repository retargets NetCoreAppCurrent to the next major version. -->
<ItemGroup>
<SupportedTestFramework Include="$(NetCoreAppCurrent)" />
<!-- TODO: Remove after the PackageTesting package in Arcade is updated. -->
<SupportedTestFramework Remove="netcoreapp3.1" />
<SupportedTestFramework Remove="net5.0" />
<SupportedTestFramework Remove="net461" />
</ItemGroup>
<GetCompatiblePackageTargetFrameworks PackagePaths="@(TestPackagesPath)"
SupportedTestFrameworks="@(SupportedTestFramework)">
<Output TaskParameter="TestProjects" ItemName="SupportedPackage" />
</GetCompatiblePackageTargetFrameworks>
<ItemGroup>
<SupportedPackage>
<ProjectDir>$(TestProjectDir)%(Identity)\</ProjectDir>
</SupportedPackage>
<SupportedPackage>
<ProjectFile>%(ProjectDir)project.csproj</ProjectFile>
</SupportedPackage>
</ItemGroup>
</Target>
<Target Name="UpdateTargetFrameworks" AfterTargets="GetSupportedPackages">
<ItemGroup>
<_supportedPackageByTargetFramework Include="@(SupportedPackage->'%(TargetFrameworkShort)')">
<Original>%(Identity)</Original>
</_supportedPackageByTargetFramework>
<_supportedPackageByTargetFrameworkToRemove Include="@(_supportedPackageByTargetFramework)" Exclude="@(TargetFrameworksToInclude)" Condition="'@(TargetFrameworksToInclude)' != ''" />
<_filteredSupportedPackageByTargetFramework Include="@(_supportedPackageByTargetFramework)" Exclude="@(_supportedPackageByTargetFrameworkToRemove)" />
<SupportedPackage Remove="@(SupportedPackage)" />
<SupportedPackage Include="@(_filteredSupportedPackageByTargetFramework->'%(Original)')" />
</ItemGroup>
</Target>
<Target Name="GenerateProjects"
DependsOnTargets="GetSupportedPackages;CreateTestDir"
Inputs="@(TestPackagesPath);$(ProjectTemplate)"
Outputs="%(SupportedPackage.ProjectFile)">
<PropertyGroup>
<_projectDir>%(SupportedPackage.ProjectDir)</_projectDir>
<_projectFile>%(SupportedPackage.ProjectFile)</_projectFile>
<_packageId>%(SupportedPackage.Identity)</_packageId>
<_packageVersion>%(SupportedPackage.Version)</_packageVersion>
<_projectTFMs>@(SupportedPackage->'%(TargetFrameworkShort)')</_projectTFMs>
</PropertyGroup>
<!-- Generate project.csproj from template. -->
<MakeDir Directories="$(_projectDir)" />
<WriteLinesToFile
File="$(_projectFile)"
Lines="$([System.IO.File]::ReadAllText('$(ProjectTemplate)').Replace('{PackageId}', $(_packageId)).Replace('{PackageVersion}', $(_packageVersion)).Replace('{TargetFrameworks}', $(_projectTFMs)).Replace('{NetCoreAppCurrent}', $(NetCoreAppCurrent)).Replace('{NetCoreAppCurrentVersion}', $(NetCoreAppCurrentVersion)).Replace('{MicrosoftNetCoreAppFrameworkName}', $(MicrosoftNetCoreAppFrameworkName)).Replace('{MicrosoftNetCoreAppRefPackDir}', $(MicrosoftNetCoreAppRefPackDir)).Replace('{RestoreAdditionalProjectSources}', $(ArtifactsPackagesDir)).Replace('{RestorePackagesPath}', $(TestPackageDir)))"
Overwrite="true" />
</Target>
<Target Name="InvokeProjects"
DependsOnTargets="GenerateProjects"
AfterTargets="Build;Test">
<ItemGroup>
<TestProject Include="$(TestDir)$(TestProjectName)" Condition="'$(PackagesToTest)' == ''" />
<TestProject Include="%(SupportedPackage.ProjectFile)" Condition="'$(PackagesToTest)' != ''" />
</ItemGroup>
<MSBuild Projects="@(TestProject)"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Targets="Restore" />
<MSBuild Projects="@(TestProject)" />
</Target>
<Target Name="Test" />
</Project>
|