-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy pathrunsettings.targets
65 lines (56 loc) · 5.27 KB
/
runsettings.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
<Project>
<PropertyGroup>
<RunSettingsInputFilePath>$(MSBuildThisFileDirectory).runsettings</RunSettingsInputFilePath>
<RunSettingsIntermediateOutputFilePath>$(ArtifactsObjDir)$(TargetOS)-$(Configuration)-$(TargetArchitecture).runsettings</RunSettingsIntermediateOutputFilePath>
<RunSettingsAppOutputFilePath>$(OutDir).runsettings</RunSettingsAppOutputFilePath>
<CreateIntermediateRunSettingsFile Condition="'$(CreateIntermediateRunSettingsFile)' == ''">false</CreateIntermediateRunSettingsFile>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' == 'true'">$(RunSettingsIntermediateOutputFilePath)</RunSettingsOutputFilePath>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' != 'true'">$(RunSettingsAppOutputFilePath)</RunSettingsOutputFilePath>
<VsCodeRunSettingsOutputFilePath>$(ArtifactsObjDir)vscode/.runsettings</VsCodeRunSettingsOutputFilePath>
<!-- Set RunSettingsFilePath property which is read by VSTest. -->
<RunSettingsFilePath Condition="Exists('$(RunSettingsAppOutputFilePath)')">$(RunSettingsAppOutputFilePath)</RunSettingsFilePath>
<!-- Use an intermediate runsettings file if the app hasn't been built yet to enable VSTest discovery. -->
<RunSettingsFilePath Condition="'$(RunSettingsFilePath)' == '' and Exists('$(RunSettingsIntermediateOutputFilePath)')">$(RunSettingsIntermediateOutputFilePath)</RunSettingsFilePath>
<GenerateRunSettingsFileDependsOn Condition="'$(EnableCoverageSupport)' == 'true'">$(GenerateRunSettingsFileDependsOn);SetupCoverageFilter</GenerateRunSettingsFileDependsOn>
<PrepareForRunDependsOn>GenerateRunSettingsFile;$(PrepareForRunDependsOn)</PrepareForRunDependsOn>
</PropertyGroup>
<PropertyGroup Condition="'$(RunSettingsTestCaseFilter)' == ''">
<_testFilter Condition="'$(_withCategories)' != ''">$(_withCategories.Replace(';', '&amp;category='))</_testFilter>
<_testFilter Condition="'$(_withoutCategories)' != ''">$(_testFilter)$(_withoutCategories.Replace(';', '&amp;category!='))</_testFilter>
<_testFilter>$(_testFilter.Trim('&amp;'))</_testFilter>
</PropertyGroup>
<Target Name="GenerateRunSettingsFile"
DependsOnTargets="$(GenerateRunSettingsFileDependsOn)">
<PropertyGroup>
<RunSettingsDotNetHostPath Condition="'$(RunSettingsDotNetHostPath)' == ''">$(NetCoreAppCurrentTestHostPath)$([System.IO.Path]::GetFileName('$(DotNetTool)'))</RunSettingsDotNetHostPath>
<RunSettingsTestCaseFilter Condition="'$(RunSettingsTestCaseFilter)' == ''">$(_testFilter)</RunSettingsTestCaseFilter>
<RunSettingsFileContent>$([System.IO.File]::ReadAllText('$(RunSettingsInputFilePath)'))</RunSettingsFileContent>
<RunSettingsFileContent Condition="'$(TestDisableParallelization)' == 'true'">$(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '1'))</RunSettingsFileContent>
<RunSettingsFileContent Condition="'$(TestDisableParallelization)' != 'true'">$(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '0'))</RunSettingsFileContent>
<!-- Arm64 is currently not a known TargetPlatform value in VSTEST: https://github.com/microsoft/vstest/issues/2566 -->
<RunSettingsFileContent Condition="'$(TargetArchitecture)' != 'arm64'">$(RunSettingsFileContent.Replace('$$TARGETPLATFORM$$', '<TargetPlatform>$(TargetArchitecture)</TargetPlatform>'))</RunSettingsFileContent>
<RunSettingsFileContent Condition="'$(TargetArchitecture)' == 'arm64'">$(RunSettingsFileContent.Replace('$$TARGETPLATFORM$$', ''))</RunSettingsFileContent>
<RunSettingsFileContent>$(RunSettingsFileContent.Replace('$$COVERAGE_INCLUDE$$', '$(CoverageIncludeFilter)')
.Replace('$$COVERAGE_EXCLUDEBYFILE$$', '$(CoverageExcludeByFileFilter)')
.Replace('$$COVERAGE_INCLUDEDIRECTORY$$', '$(CoverageIncludeDirectoryFilter)')
.Replace('$$COVERAGE_ENABLED$$', '$([MSBuild]::ValueOrDefault('$(Coverage)', 'false'))')
.Replace('$$DISABLEPARALLELIZATION$$', '$([MSBuild]::ValueOrDefault('$(TestDisableParallelization)', 'false'))')
.Replace('$$DISABLEAPPDOMAIN$$', '$([MSBuild]::ValueOrDefault('$(TestDisableAppDomain)', 'false'))')
.Replace('$$TESTCASEFILTER$$', '$(RunSettingsTestCaseFilter)')
.Replace('$$DOTNETHOSTPATH$$', '$(RunSettingsDotNetHostPath)'))</RunSettingsFileContent>
</PropertyGroup>
<WriteLinesToFile File="$(RunSettingsOutputFilePath)"
Lines="$(RunSettingsFileContent)"
WriteOnlyWhenDifferent="true"
Overwrite="true" />
<WriteLinesToFile File="$(VsCodeRunSettingsOutputFilePath)"
Lines="$(RunSettingsFileContent)"
WriteOnlyWhenDifferent="true"
Overwrite="true"
Condition="'$(CreateVsCodeRunSettingsFile)' == 'true'" />
<!-- Set RunSettingsFilePath property which is read by VSTest. -->
<PropertyGroup>
<RunSettingsFilePath>$(RunSettingsOutputFilePath)</RunSettingsFilePath>
</PropertyGroup>
</Target>
</Project>