forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dir.targets
175 lines (144 loc) · 9.94 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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)\**\*.*"/>
<!-- Avoid race condition between project's IncrementalClean coming along to delete the .pdb and this project copying it. -->
<OutputItems Remove="$(OutputPath)\**\*.pdb" Condition="'$(DebugType)' == 'embedded'" />
</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>
<!-- We want this target to be incremental, but editbin affects the file in place, as does
OpenSourceSign. So run this target when the assembly has been updated since the last
time it was signed. Signing will run immediately after this, flipping another bit and
dropping the marker file. -->
<Target Name="EditBin"
AfterTargets="CoreCompile"
BeforeTargets="OpenSourceSign"
Inputs="@(IntermediateAssembly)"
Outputs="@(IntermediateAssembly->'%(Identity).oss_signed')"
Condition="'$(FullFrameworkBuild)' == 'true' and '$(PlatformTarget)' == 'x86'">
<PropertyGroup>
<!-- Native equivalent is /LARGEADDRESSAWARE on the linker -->
<EditBinFlags Condition="'$(LargeAddressAware)'=='true'">$(EditBinFlags) /LARGEADDRESSAWARE</EditBinFlags>
<!-- Don't require all developers to install C++ tools just to
get editbin.exe -->
<EditBinContinueOnError>WarnAndContinue</EditBinContinueOnError>
<!-- But DO fail the build on CI and official builds if we can't
produce the right outputs. Continuing on error to allow
test results even on a misconfigured build machine. -->
<EditBinContinueOnError Condition="'$(TF_BUILD)' == 'True' or '$(JENKINS_URL)' != ''">ErrorAndContinue</EditBinContinueOnError>
<!--
* VSINSTALLDIR is set by the Developer Command Prompt. When building from MicroBuild, this isn't set.
* VsInstallRoot is discovered by MSBuild, but in our bootstrapped build it's wrong (VS isn't installed
to our 'bin' folder). When building from MicroBuild (or any installed VS), this value is correct.
-->
<EditBinCommand Condition="'$(VSINSTALLDIR)' != ''">call "$(VSINSTALLDIR)\Common7\Tools\VsDevCmd.bat" /no_logo&& editbin.exe /NOLOGO $(EditBinFlags) @(IntermediateAssembly)</EditBinCommand>
<EditBinCommand Condition="'$(VsInstallRoot)' != '' and '$(EditBinCommand)' == ''">call "$(VsInstallRoot)\Common7\Tools\VsDevCmd.bat" /no_logo&& editbin.exe /NOLOGO $(EditBinFlags) @(IntermediateAssembly)</EditBinCommand>
</PropertyGroup>
<Exec Condition="'$(EditBinFlags)'!=''"
Command="$(EditBinCommand)"
ContinueOnError="$(EditBinContinueOnError)" />
</Target>
<Import Project="$(NuGetConfigDir)\packageLoad.targets" />
</Project>