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)')"/>
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)')"
118 DependsOnTargets="GenerateExecutionScriptsInternal" />
120 <Target Name="CopyNativeProjectBinaries">
122 <NativeProjectBinaries Include="$(NativeProjectOutputFolder)\**\*.*" />
125 <Error Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once"
126 Condition="'@(NativeProjectBinaries)' == ''" />
129 SourceFiles="@(NativeProjectBinaries)"
130 DestinationFiles="@(NativeProjectBinaries -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')"
131 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
132 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
133 Retries="$(CopyRetryCount)"
134 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
135 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
136 <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
140 <Target Name="ResolveCmakeNativeProjectReference"
141 Condition="'@(ProjectReference)' != ''"
142 BeforeTargets="BeforeResolveReferences;BeforeClean" >
144 <NativeProjectReference Include="%(ProjectReference.Identity)" Condition="$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) == 'CMAKELISTS'" />
145 <ProjectReference Remove="%(NativeProjectReference.Identity)" />
146 <NativeProjectReferenceNormalized Include="@(NativeProjectReference -> '%(FullPath)')" />
150 <Target Name="ConsolidateNativeProjectReference"
151 Condition="'@(NativeProjectReferenceNormalized)' != ''"
152 BeforeTargets="Build" >
154 <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))" Condition="'$(RunningOnUnix)' == 'true'" />
155 <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))$(Configuration)\" Condition="'$(RunningOnUnix)' != 'true'" />
158 <Message Text= "Full native project references are :%(NativeProjectReferenceNormalized.Identity)" />
159 <Message Text= "Native binaries will be copied from :%(NativeProjectOutputFoldersToCopy.Identity)" />
160 <MSBuild Projects="$(MSBuildProjectFile)" Targets="CopyNativeProjectBinaries" Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity)" Condition="'@(NativeProjectReference)' != '' And '$(RunningOnUnix)' != 'true'" />
165 <PrepareForRunDependsOn>$(PrepareForRunDependsOn);ResetReferenceCopyLocalPaths</PrepareForRunDependsOn>
168 <Target Name="ResetReferenceCopyLocalPaths"
169 Condition="'@(ReferenceCopyLocalPaths)' != ''"
170 BeforeTargets="_CopyFilesMarkedCopyLocal">
172 <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.CopyLocal)' != 'true'"/>
176 <Target Name="UpdateReferenceItems"
177 BeforeTargets="BeforeResolveReferences"
180 <Reference Include="$(TargetingPackPath)/*.dll" >
181 <Private>false</Private>
187 <Target Name="AfterBuild">
188 <Copy SourceFiles="$(AssemblyName).reflect.xml"
189 DestinationFolder="$(OutputPath)"
190 Condition="Exists('$(AssemblyName).reflect.xml')"/>
194 <ProjectAssetsFile>$(SourceDir)Common\test_dependencies\obj\project.assets.json</ProjectAssetsFile>
197 <PropertyGroup Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'">
198 <ProjectAssetsFile></ProjectAssetsFile>