forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
104 lines (88 loc) · 5.06 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
104 lines (88 loc) · 5.06 KB
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
<Project>
<!-- Exclude any ProjectReferences to framework assemblies on the latest framework -->
<Import Project="$(LibrariesProjectRoot)NetCoreAppLibrary.props" Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'" />
<ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
<ProjectReferenceExclusion Include="@(NetCoreAppLibrary)" />
</ItemGroup>
<Target Name="GetTargetDir" Returns="$([System.IO.Path]::GetFullPath('$(TargetDir)'))" />
<Target Name="SetupTestContextVariables"
Condition="'$(IsTestProject)' == 'true'"
DependsOnTargets="
DetermineTestOutputDirectory"
BeforeTargets="Build">
<PropertyGroup>
<!--
The tests use the TEST_ARTIFACTS variable to determine the artifacts folder and then later
compare that path to its expected path. So, the TEST_ARTIFACTS variable has to have system
specific path separators or the string compoarison will fail.
-->
<DirectorySeparatorChar>$([System.IO.Path]::DirectorySeparatorChar)</DirectorySeparatorChar>
<SystemPathTestsOutputDir>$(TestsOutputDir.Replace('/', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
<SystemPathTestsOutputDir>$(SystemPathTestsOutputDir.Replace('\', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
<!-- This is defined when building in Visual Studio, not DotNetRoot. -->
<DotNetRoot Condition="'$(DotNetRoot)' == ''">$(NetCoreRoot)</DotNetRoot>
</PropertyGroup>
<!--
Fetch the package version of Microsoft.NETCore.App. Use the runtime nupkg project because it
always ships.
Some test projects end in ".Tests", which Arcade detects and applies IsShipping=false. This
makes ProductVersion non-stable, so we can't rely on the test project's ProductVersion to be
the same as the package's version. Fetch this directly from the project to avoid guesswork.
-->
<MSBuild
Projects="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Ref.sfxproj"
Targets="ReturnProductVersion">
<Output TaskParameter="TargetOutputs" PropertyName="NETCoreAppRuntimePackageVersion" />
</MSBuild>
<!--
Set up properties used inside tests. Write them to a text file so that they can be found
inside the VS Test Explorer context the same way as the XUnit runner will find them.
See https://github.com/dotnet/arcade/issues/3077.
-->
<ItemGroup>
<TestContextVariable Include="TEST_ARTIFACTS=$(SystemPathTestsOutputDir)" />
<TestContextVariable Include="BUILD_RID=$(TargetRid)" />
<TestContextVariable Include="BUILD_ARCHITECTURE=$(TargetArchitecture)" />
<TestContextVariable Include="BUILD_CONFIGURATION=$(Configuration)" />
<TestContextVariable Include="MNA_VERSION=$(NETCoreAppRuntimePackageVersion)" />
<TestContextVariable Include="MNA_TFM=$(NetCoreAppCurrent)" />
<TestContextVariable Include="TEST_ASSETS_OUTPUT=$(TestArtifactsOutputRoot)" />
</ItemGroup>
<WriteLinesToFile
File="$(OutDir)TestContextVariables.txt"
Overwrite="true"
Lines="@(TestContextVariable)" />
<!-- Write an empty global.json to the output, such that running the test -->
<WriteLinesToFile
File="$(OutDir)global.json"
Lines="{}"
WriteOnlyWhenDifferent="true" />
</Target>
<Target Name="DetermineTestOutputDirectory">
<PropertyGroup>
<TestsOutputName Condition="'$(TestsOutputName)' == ''">$(MSBuildProjectName)</TestsOutputName>
<TestsOutputDir Condition="'$(TestsOutputDir)' == ''">$(TestArtifactsOutputRoot)$(TestsOutputName)/</TestsOutputDir>
</PropertyGroup>
</Target>
<Target Name="RemoveOOBPackageReference" AfterTargets="ResolvePackageAssets">
<!-- Tests have some dependencies that use the System.Text.Json package (HostModel, DependencyModel),
but the tests should just use the framework on which they are run if possible Explicitly remove
the item if the target framework version for the test matches the referenced package version. -->
<ItemGroup>
<RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)"
Condition="'%(NuGetPackageId)' == 'System.Text.Json' and $(SystemTextJsonVersion.StartsWith('$(_TargetFrameworkVersionWithoutV)'))" />
</ItemGroup>
</Target>
<!-- Properties used by runsettings.targets -->
<PropertyGroup>
<RunSettingsDotNetHostPath>$(DotNetTool)</RunSettingsDotNetHostPath>
<RunSettingsTestCaseFilter>$(TestCaseFilter)</RunSettingsTestCaseFilter>
</PropertyGroup>
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="$(MicrosoftTestingPlatformVersion)" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)testing\runsettings.targets"
Condition="'$(IsTestProject)' == 'true'" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
</Project>