1 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <!-- Default priority building values. -->
4 <CLRTestKind Condition="'$(CLRTestKind)' == '' and '$(OutputType)' == 'Library'">SharedLibrary</CLRTestKind>
5 <CLRTestKind Condition="'$(CLRTestKind)' == ''">BuildAndRun</CLRTestKind>
6 <CLRTestPriority Condition="'$(CLRTestPriority)' == ''">0</CLRTestPriority>
9 <PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
10 <!-- Many parts of the tests expect the output file to be an exe. We override the extension to match here, but in future we should probably update the infrastructure to look for dlls -->
11 <TargetExt Condition="'$(OutputType)' == 'Exe' and '$(TargetExt)' == '.dll'">.exe</TargetExt>
14 <!-- All CLRTests need to be of a certain "kind". These kinds are enumerated below.
15 By default all tests are BuildAndRun. This means that the build system will Build them
16 and construct a run-batch-script for them. -->
18 <When Condition=" '$(CLRTestKind)'=='SharedLibrary'">
20 <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
21 <_CLRTestNeedsToRun>false</_CLRTestNeedsToRun>
22 <GenerateRunScript>false</GenerateRunScript>
23 <_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable>
26 <When Condition=" '$(CLRTestKind)'=='BuildAndRun' ">
28 <GenerateRunScript>true</GenerateRunScript>
29 <_CLRTestNeedsToRun>true</_CLRTestNeedsToRun>
30 <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
31 <_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable>
34 <When Condition=" '$(CLRTestKind)'=='BuildOnly'">
36 <_CLRTestNeedsToRun>false</_CLRTestNeedsToRun>
37 <GenerateRunScript>false</GenerateRunScript>
38 <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
39 <_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable>
42 <When Condition=" '$(CLRTestKind)'=='RunOnly' ">
44 <GenerateRunScript>true</GenerateRunScript>
45 <SkipSigning>true</SkipSigning>
46 <_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable>
47 <_CLRTestNeedsToRun>true</_CLRTestNeedsToRun>
48 <_CLRTestCompilesSource>false</_CLRTestCompilesSource>
54 <_CLRTestNeedsProjectToRun>false</_CLRTestNeedsProjectToRun>
55 <_CLRTestNeedsProjectToRun Condition=" '$(_CLRTestNeedsToRun)' and '!$(_CLRTestBuildsExecutable)' ">true</_CLRTestNeedsProjectToRun>
59 <!-- Since bug in Roslyn for Linux empty DebugType property leads to build failure. See issue Roslyn@20343 -->
60 <DebugType Condition=" '$(DebugType)' == '' and '$(RunningOnUnix)' == 'true' ">None</DebugType>
64 If it needs ProjectToRun, turn the project into a ProjectReference so it gets built
66 <ItemGroup Condition=" $(_CLRTestNeedsProjectToRun) ">
67 <ProjectReference Include="$(CLRTestProjectToRun)">
68 <Private>false</Private>
73 <ErrorIfBuildToolsRestoredFromIndividualProject Condition="!Exists('$(ToolsDir)')">true</ErrorIfBuildToolsRestoredFromIndividualProject>
76 <Import Project="..\dir.targets" />
78 <!-- Determine if this project should be built or not -->
80 <BuildAllProjects Condition="'$(BuildAllProjects)' == ''">false</BuildAllProjects>
81 <_WillCLRTestProjectBuild Condition="'$(_WillCLRTestProjectBuild)' == ''">false</_WillCLRTestProjectBuild>
82 <_WillCLRTestProjectBuild Condition="'$(BuildAllProjects)' != 'true'">true</_WillCLRTestProjectBuild>
83 <_WillCLRTestProjectBuild Condition="'$(DisableProjectBuild)' != 'true' And '$(BuildAllProjects)' == 'true' And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'">true</_WillCLRTestProjectBuild>
86 <!-- if we have determined that there is nothing to build, overwrite the build targets so that nothing happens -->
87 <Import Project="nobuild.targets" Condition="'$(_WillCLRTestProjectBuild)' == 'false'" />
89 <!-- RunOnly projects have a special build for dependent projects -->
90 <Import Project="runonly.targets" Condition="'$(CLRTestKind)' == 'RunOnly'" />
92 <!-- We will use an imported build here in the instance that we're a non-sdk style project, have source that we need to build, and we are the correct priority...OR if we are being asked to build for
93 a test with a higher priority. -->
94 <Import Project="$(ToolsDir)Build.Common.targets" Condition="('$(UsingMicrosoftNETSdk)' != 'true') And ('$(CLRTestKind)'!='RunOnly') And $(_CLRTestCompilesSource) And ('$(_WillCLRTestProjectBuild)' == 'true')"/>
97 <Import Project="..\override.targets" Condition="Exists('..\override.targets')"/>
99 <!-- We enable auto-unification of assembly references after importing the common targets. Binding redirects are not needed
100 for coreclr since it auto-unifies, so the warnings we get without this setting are just noise -->
102 <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
105 <!-- Project language -->
106 <!-- TODO: This might just be the Language property -->
107 <PropertyGroup Condition="'$(ProjectLanguage)' == ''">
108 <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.ilproj' OR '$(Language)' == 'IL'">IL</ProjectLanguage>
109 <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage>
111 <SkipImportILTargets Condition="'$(CLRTestPriority)' > '$(CLRTestPriorityToBuild)'">true</SkipImportILTargets>
114 <Import Project="CLRTest.Execute.targets" />
115 <Target Name="CreateExecuteScript"
117 Condition="'$(GenerateRunScript)' != 'false' And ('$(_WillCLRTestProjectBuild)' == 'true')"
118 DependsOnTargets="GenerateExecutionScriptsInternal" />
120 <Target Name="CopyNativeProjectBinaries">
122 <NativeProjectBinaries Condition="'$(RunningOnUnix)' != 'true'" Include="$(NativeProjectOutputFolder)\**\*.*" />
124 <!-- ############################################################### -->
125 <!-- The following is unix only. It is required because the unix test-->
126 <!-- build, unlike the windows test build, do not place the binaries -->
127 <!-- built into a separate Debug/Checked/Release directory. Therefore-->
128 <!-- we must filter the folder to only include dynamic libraries, -->
129 <!-- static libraries and executables. -->
131 <!-- Please take care when modifying the following lines of code. -->
132 <!-- At a minimum to test any changes to the below, please run a -->
133 <!-- pri1 test build. -->
134 <!-- ############################################################### -->
136 <!-- Include everything and then filter. -->
137 <NativeProjectBinariesMatched Condition="'$(RunningOnUnix)' == 'true'" Include="$(NativeProjectOutputFolder)\**\*.*" />
139 <!-- Filter executables on unix -->
140 <NativeProjectBinariesExeFilter Condition="'$(RunningOnUnix)' == 'true' and $([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `(.*\/)([^.]+)$`))" Include="@(NativeProjectBinariesMatched)" />
141 <!-- Filter out the *Make* files -->
142 <NativeProjectBinariesExeFilterRemovedMakeFile Condition="'$(RunningOnUnix)' == 'true' and !$([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `.*Makefile.*`))" Include="@(NativeProjectBinariesExeFilter)" />
144 <!-- Filter out the CMakeFiles files -->
145 <NativeProjectBinariesExeFilterRemovedCMakeFile Condition="'$(RunningOnUnix)' == 'true' and !$([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `.*CMakeFiles.*`))" Include="@(NativeProjectBinariesExeFilterRemovedMakeFile)" />
147 <!-- Filter .dylib files on OSX -->
148 <NativeProjectBinariesDyLibFilter Condition="'$(__BuildOS)' == 'OSX' and $([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `(.*\/).*\.dylib`))" Include="@(NativeProjectBinariesMatched)" />
150 <!-- Filter .so files on Linux -->
151 <NativeProjectBinariesDyLibFilter Condition="'$(__BuildOS)' == 'Linux' and $([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `(.*\/).*\.so`))" Include="@(NativeProjectBinariesMatched)" />
153 <!-- Filter static lib files on Unix -->
154 <NativeProjectBinariesStaticLibFilter Condition="'$(RunningOnUnix)' == 'true' and $([System.Text.RegularExpressions.Regex]::IsMatch(['%(Identity)', `(.*\/).*\.a`))" Include="@(NativeProjectBinariesMatched)" />
156 <!-- Merge the filtered lists -->
157 <NativeProjectBinaries Condition="'$(RunningOnUnix)' == 'true'" Include="@(NativeProjectBinariesExeFilterRemovedCMakeFile)" />
158 <NativeProjectBinaries Condition="'$(RunningOnUnix)' == 'true'" Include="@(NativeProjectBinariesDyLibFilter)" />
159 <NativeProjectBinaries Condition="'$(RunningOnUnix)' == 'true'" Include="@(NativeProjectBinariesStaticLibFilter)" />
163 <Error Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once"
164 Condition="'@(NativeProjectBinaries)' == ''" />
167 SourceFiles="@(NativeProjectBinaries)"
168 DestinationFiles="@(NativeProjectBinaries -> '$(OutDir)%(Filename)%(Extension)')"
169 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
170 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
171 Retries="$(CopyRetryCount)"
172 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
173 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
174 <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
178 <Target Name="ResolveCmakeNativeProjectReference"
179 Condition="'@(ProjectReference)' != ''"
180 BeforeTargets="BeforeResolveReferences;BeforeClean" >
182 <NativeProjectReference Include="%(ProjectReference.Identity)" Condition="$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) == 'CMAKELISTS'" />
183 <ProjectReference Remove="%(NativeProjectReference.Identity)" />
184 <NativeProjectReferenceNormalized Include="@(NativeProjectReference -> '%(FullPath)')" />
188 <Target Name="ConsolidateNativeProjectReference"
189 Condition="'@(NativeProjectReferenceNormalized)' != ''"
190 BeforeTargets="Build" >
192 <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))" Condition="'$(RunningOnUnix)' == 'true'" />
193 <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))$(Configuration)\" Condition="'$(RunningOnUnix)' != 'true'" />
196 <Message Text= "Full native project references are :%(NativeProjectReferenceNormalized.Identity)" />
197 <Message Text= "Native binaries will be copied from :%(NativeProjectOutputFoldersToCopy.Identity)" />
198 <MSBuild Projects="$(MSBuildProjectFile)" Targets="CopyNativeProjectBinaries" Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity)" Condition="'@(NativeProjectReference)' != ''" />
203 <PrepareForRunDependsOn>$(PrepareForRunDependsOn);ResetReferenceCopyLocalPaths</PrepareForRunDependsOn>
206 <Target Name="ResetReferenceCopyLocalPaths"
207 Condition="'@(ReferenceCopyLocalPaths)' != ''"
208 BeforeTargets="_CopyFilesMarkedCopyLocal">
210 <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.CopyLocal)' != 'true'"/>
214 <Target Name="UpdateReferenceItems"
215 BeforeTargets="BeforeResolveReferences"
218 <Reference Include="$(TargetingPackPath)/*.dll" >
219 <Private>false</Private>
225 <Target Name="AfterBuild">
226 <Copy SourceFiles="$(AssemblyName).reflect.xml"
227 DestinationFolder="$(OutputPath)"
228 Condition="Exists('$(AssemblyName).reflect.xml')"/>
232 <ProjectAssetsFile>$(SourceDir)Common\test_dependencies\obj-$(TargetRid)\project.assets.json</ProjectAssetsFile>
235 <PropertyGroup Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'">
236 <ProjectAssetsFile></ProjectAssetsFile>
239 <Import Project="../../clr.featuredefines.props" />