forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdir.targets
135 lines (110 loc) · 7.46 KB
/
dir.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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CheckDesignTime">
<Target Name="_DisplayBuildInfo">
<!-- Cannot do both MonoBuild and NetCoreBuild -->
<Error Condition="'$(MonoBuild)' == 'true' and '$(NetCoreBuild)' == 'true'"
Text="Cannot do both Mono and NetCore build."
/>
<Message Importance="High" Text="Build '$(MSBuildProjectFile)' into binary directory '$(BaseOutputPathWithConfig)'" />
</Target>
<!-- Provide default targets which can be hooked onto or overridden as necessary -->
<Target Name="BuildAndTest" DependsOnTargets="Build;Test" />
<Target Name="RebuildAndTest" DependsOnTargets="Rebuild;Test" />
<Target Name="Test" />
<Target Name="EnsureDependenciesDeployed"
Condition="'$(DeployDependencies)' != 'false'"
AfterTargets="Build">
<MSBuild Projects="$(RepoRoot)\targets\DeployDependencies.proj"
Targets="DeployDependencies"
BuildInParallel="true"
/>
</Target>
<Target Name="EnsurePrerequisitesCopied"
Condition="'$(IsTestProject)' == 'true'">
<MSBuild Projects="$(RepoRoot)\targets\CopyTestPrerequisites.proj"
Targets="CopyPrerequisites"
BuildInParallel="true" />
</Target>
<!-- Respect the traits set up by PlatformSpecific attribute. -->
<PropertyGroup>
<XunitOptions Condition="'$(OS)'=='Windows_NT'">$(XunitOptions) -notrait category=nonwindowstests</XunitOptions>
<XunitOptions Condition="'$(OS)'=='Unix'">$(XunitOptions) -notrait category=nonlinuxtests</XunitOptions>
<XunitOptions Condition="'$(OS)'=='Unix' and '$(NetCoreBuild)'=='true'">-notrait category=nonlinuxtests -notrait category=netcore-linux-failing</XunitOptions>
<XunitOptions Condition="'$(OS)'=='OSX'">$(XunitOptions) -notrait category=nonosxtests</XunitOptions>
<XunitOptions Condition="'$(OS)'=='OSX' and '$(NetCoreBuild)'=='true'">-notrait category=nonosxtests -notrait category=netcore-osx-failing</XunitOptions>
<XunitOptions Condition="'$(OS)'=='FreeBSD'">$(XunitOptions) -notrait category=nonfreebsdtests</XunitOptions>
<XunitOptions Condition="'$(MonoBuild)' == 'true'">$(XunitOptions) -notrait category=non-mono-tests</XunitOptions>
<XunitOptions Condition="'$(OS)'=='OSX' and '$(MonoBuild)' == 'true'">$(XunitOptions) -notrait category=mono-osx-failing</XunitOptions>
<XunitOptions Condition="'$(OS)'=='Windows_NT' and '$(MonoBuild)' == 'true'">$(XunitOptions) -notrait category=mono-windows-failing</XunitOptions>
</PropertyGroup>
<PropertyGroup Condition="'$(JENKINS_URL)' != ''">
<!-- Properties for when the tests are running in Jenkins -->
<XunitOptions Condition="'$(NetCoreBuild)' == 'true'">$(XunitOptions) -showprogress</XunitOptions>
<XunitOptions Condition="'$(NetCoreBuild)' != 'true'">$(XunitOptions) -verbose</XunitOptions>
</PropertyGroup>
<Target Name="CopyBuildOutputToDeploymentDirectories"
Condition="'$(CopyBuildOutputToDeploymentDirectories)' != 'false'">
<ItemGroup>
<OutputItems Include="$(OutputPath)\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(OutputItems)"
DestinationFolder="$(DeploymentDir)\%(RecursiveDir)"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="@(OutputItems)"
DestinationFolder="$(TestDeploymentDir)\%(RecursiveDir)"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="$(SourceDir)\Shared\UnitTests\App.config"
DestinationFiles="$(TestDeploymentDir)\MSBuild.exe.config"
/>
</Target>
<Target Name="DeployForTargetRuntime"
AfterTargets="Build"
DependsOnTargets="CopyBuildOutputToDeploymentDirectories;EnsureDependenciesDeployed">
</Target>
<Target Name="Test"
DependsOnTargets="Build;CopyBuildOutputToDeploymentDirectories;EnsureDependenciesDeployed;EnsurePrerequisitesCopied"
Condition="'$(IsTestProject)' == 'true'">
<ItemGroup>
<AssemblyUnderTest Include="@(MainAssembly->'$(TestDeploymentDir)\%(Filename)%(Extension)')"/>
</ItemGroup>
<!-- Exec the console runner instead of using the MSBuild runner,
because our tests have dependencies on being run as x86. -->
<!-- Noshadow because our assemblies do not pass the checks for it
(due to open source signing). -->
<!-- No parallel execution because most of our tests do bad things
with state. They were passing because MSTest was serial. -->
<Message Importance="High" Text="xunit -> %(MainAssembly.Filename)..." />
<!-- Run tests on the full framework -->
<Exec Command="$(ToolPackagesDir)\xunit.runner.console\$(XunitVersion)\tools\xunit.console.x86.exe @(AssemblyUnderTest, ' ') $(XunitOptions) -noshadow -parallel none -xml %(AssemblyUnderTest.FullPath)_TestResults.xml -html %(AssemblyUnderTest.FullPath)_TestResults.html > %(AssemblyUnderTest.FullPath)_stdout.txt"
Condition="'$(NetCoreBuild)' != 'true'" />
<!-- Run tests using coreclr. Ignore warnings/errors generated by tests to stderr. -->
<Exec Command="$(DotnetToolCommand) $(TestDeploymentDir)xunit.console.netcore.exe @(AssemblyUnderTest, ' ') $(XunitOptions) -noshadow -parallel none -notrait "CrashesOnNetCore=true" -xml %(AssemblyUnderTest.FullPath)_core_TestResults.xml $(XunitOptions) > %(AssemblyUnderTest.FullPath)_core_stdout.txt"
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="MSBUILDDONOTLAUNCHDEBUGGER=1"
Condition="'$(NetCoreBuild)' == 'true'" />
</Target>
<Target Name="EnsureSDKTargetPresent"
BeforeTargets="_DisplayBuildInfo"
Condition="'$(NetCoreBuild)' != 'true' and '$(OsEnvironment)'=='Windows_NT'">
<Error Condition="!Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets')"
Text="File not found: '$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets'. This is a file generated by the Visual Studio Windows SDK plugin that MSBuild depends on. Please install the plugin. Reference: https://github.com/Microsoft/msbuild/wiki/Building+Testing+and+Debugging" />
</Target>
<!-- Prevent the build tools restore from entering infinite restore during VS design time build -->
<!-- https://github.com/dotnet/buildtools/blob/master/src/Microsoft.DotNet.Build.Tasks/PackageFiles/packageresolve.targets#L23 -->
<!-- Copied from: https://github.com/dotnet/buildtools/blob/master/src/Microsoft.DotNet.Build.Tasks/PackageFiles/Build.Common.targets#L189 -->
<!-- TODO: remove this target when we solely rely on Build.Common.targets from Build Tools -->
<Target Name="CheckDesignTime">
<!--
Visual Studio does a number of background builds to do a variety of tasks such as resolving references and preparing for intellisense.
These are called "design time" builds. You can only determine this state within a target as the properties VS sets are added at build time.
To see design time logs set TRACEDESIGNTIME=true before launching Visual Studio. Logs will go to %TEMP%.
Note that the existing $(DesignTimeBuild) is not set for all background builds.
-->
<PropertyGroup>
<VSDesignTimeBuild Condition="'$(BuildingInsideVisualStudio)'=='true' and '$(BuildingOutOfProcess)'=='false'">true</VSDesignTimeBuild>
</PropertyGroup>
</Target>
<Import Project="$(NuGetConfigDir)\packageLoad.targets" />
</Project>