| 1 |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 2 |
<!-- Default priority building values. --> |
| 3 |
<PropertyGroup> |
| 4 |
<CLRTestKind Condition="'$(CLRTestKind)' == '' and '$(OutputType)' == 'Library'">SharedLibrary</CLRTestKind> |
| 5 |
<CLRTestKind Condition="'$(CLRTestKind)' == ''">BuildAndRun</CLRTestKind> |
| 6 |
<CLRTestPriority Condition="'$(CLRTestPriority)' == ''">0</CLRTestPriority> |
| 7 |
</PropertyGroup> |
| 8 |
|
| 9 |
<!-- All CLRTests need to be of a certain "kind". These kinds are enumerated below. |
| 10 |
By default all tests are BuildAndRun. This means that the build system will Build them |
| 11 |
and construct a run-batch-script for them. --> |
| 12 |
<Choose> |
| 13 |
<When Condition=" '$(CLRTestKind)'=='SharedLibrary'"> |
| 14 |
<PropertyGroup> |
| 15 |
<_CLRTestCompilesSource>true</_CLRTestCompilesSource> |
| 16 |
<_CLRTestNeedsToRun>false</_CLRTestNeedsToRun> |
| 17 |
<GenerateRunScript>false</GenerateRunScript> |
| 18 |
<_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable> |
| 19 |
</PropertyGroup> |
| 20 |
</When> |
| 21 |
<When Condition=" '$(CLRTestKind)'=='BuildAndRun' "> |
| 22 |
<PropertyGroup> |
| 23 |
<GenerateRunScript>true</GenerateRunScript> |
| 24 |
<_CLRTestNeedsToRun>true</_CLRTestNeedsToRun> |
| 25 |
<_CLRTestCompilesSource>true</_CLRTestCompilesSource> |
| 26 |
<_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable> |
| 27 |
</PropertyGroup> |
| 28 |
</When> |
| 29 |
<When Condition=" '$(CLRTestKind)'=='BuildOnly'"> |
| 30 |
<PropertyGroup> |
| 31 |
<_CLRTestNeedsToRun>false</_CLRTestNeedsToRun> |
| 32 |
<GenerateRunScript>false</GenerateRunScript> |
| 33 |
<_CLRTestCompilesSource>true</_CLRTestCompilesSource> |
| 34 |
<_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable> |
| 35 |
</PropertyGroup> |
| 36 |
</When> |
| 37 |
<When Condition=" '$(CLRTestKind)'=='RunOnly' "> |
| 38 |
<PropertyGroup> |
| 39 |
<GenerateRunScript>true</GenerateRunScript> |
| 40 |
<SkipSigning>true</SkipSigning> |
| 41 |
<_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable> |
| 42 |
<_CLRTestNeedsToRun>true</_CLRTestNeedsToRun> |
| 43 |
<_CLRTestCompilesSource>false</_CLRTestCompilesSource> |
| 44 |
</PropertyGroup> |
| 45 |
</When> |
| 46 |
</Choose> |
| 47 |
|
| 48 |
<PropertyGroup> |
| 49 |
<_CLRTestNeedsProjectToRun>false</_CLRTestNeedsProjectToRun> |
| 50 |
<_CLRTestNeedsProjectToRun Condition=" '$(_CLRTestNeedsToRun)' and '!$(_CLRTestBuildsExecutable)' ">true</_CLRTestNeedsProjectToRun> |
| 51 |
</PropertyGroup> |
| 52 |
|
| 53 |
<!-- |
| 54 |
If it needs ProjectToRun, turn the project into a ProjectReference so it gets built |
| 55 |
--> |
| 56 |
<ItemGroup Condition=" $(_CLRTestNeedsProjectToRun) "> |
| 57 |
<ProjectReference Include="$(CLRTestProjectToRun)"> |
| 58 |
<Private>false</Private> |
| 59 |
</ProjectReference> |
| 60 |
</ItemGroup> |
| 61 |
|
| 62 |
<Import Project="..\dir.targets" /> |
| 63 |
|
| 64 |
<Target Name="CreateManifestResourceNames" /> |
| 65 |
<Target Name="CoreCompile" /> |
| 66 |
|
| 67 |
<!-- If we are a run-only, that depends on another project, this is the "Build" we use. I.e. build all dependency projects, absolutely. |
| 68 |
--> |
| 69 |
|
| 70 |
<PropertyGroup> |
| 71 |
<BuildAllProjects Condition=" '$(BuildAllProjects)' == ''">false</BuildAllProjects> |
| 72 |
<_WillCLRTestProjectBuild Condition="'$(_WillCLRTestProjectBuild)' == ''">false</_WillCLRTestProjectBuild> |
| 73 |
<_WillCLRTestProjectBuild Condition="'$(BuildAllProjects)' != true">true</_WillCLRTestProjectBuild> |
| 74 |
<_WillCLRTestProjectBuild Condition="'$(DisableProjectBuild)' != true And '$(BuildAllProjects)' == true And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'">true</_WillCLRTestProjectBuild> |
| 75 |
</PropertyGroup> |
| 76 |
|
| 77 |
<Target Name="Build" Condition="('$(CLRTestKind)'=='RunOnly') And '$(_WillCLRTestProjectBuild)'"> |
| 78 |
<MSBuild Projects="@(ProjectReference)" /> |
| 79 |
<MakeDir Condition="'$(CLRTestKind)' == 'RunOnly'" ContinueOnError="false" Directories="$(OutputPath)" /> |
| 80 |
</Target> |
| 81 |
|
| 82 |
<Target Name="CopyJsonProjectFiles" AfterTargets="Build"> |
| 83 |
<!-- Post build copy project json files so we can generate assembly lists for the projects --> |
| 84 |
<Copy SourceFiles="$(ProjectLockJson)" DestinationFolder="$(OutputPath)" Condition="Exists('$(ProjectLockJson)')" /> |
| 85 |
</Target> |
| 86 |
|
| 87 |
<!-- We will use an imported build here in the instance that we have source that we need to build, and we are the correct priority...OR if we are being asked to build for |
| 88 |
a test with a higher priority. --> |
| 89 |
<Import Project="$(ToolsDir)Build.Common.targets" Condition="('$(CLRTestKind)'!='RunOnly') And $(_CLRTestCompilesSource) And ('$(_WillCLRTestProjectBuild)')"/> |
| 90 |
|
| 91 |
|
| 92 |
<Import Project="..\override.targets" Condition="Exists('..\override.targets')"/> |
| 93 |
|
| 94 |
<!-- We enable auto-unification of assembly references after importing the common targets. Binding redirects are not needed |
| 95 |
for coreclr since it auto-unifies, so the warnings we get without this setting are just noise --> |
| 96 |
<PropertyGroup> |
| 97 |
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences> |
| 98 |
</PropertyGroup> |
| 99 |
|
| 100 |
<!-- Project language --> |
| 101 |
<!-- TODO: This might just be the Language property --> |
| 102 |
<PropertyGroup Condition="'$(ProjectLanguage)' == ''"> |
| 103 |
<ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.ilproj' OR '$(Language)' == 'IL'">IL</ProjectLanguage> |
| 104 |
<ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage> |
| 105 |
</PropertyGroup> |
| 106 |
|
| 107 |
<!-- TODO (#1122): import this from the ToolsDir once it becomes available --> |
| 108 |
<Import Project="$(ProjectDir)src\IL.targets" Condition="'$(ProjectLanguage)' == 'IL' And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'" /> |
| 109 |
|
| 110 |
<!-- |
| 111 |
We don't need to build cmd files when using a test drop |
| 112 |
<Import Project="CLRTest.Execute.targets" /> |
| 113 |
--> |
| 114 |
<Target Name="CreateExecuteScript" |
| 115 |
AfterTargets="Build" |
| 116 |
Condition="'$(GenerateRunScript)' != 'false' And ('$(_WillCLRTestProjectBuild)')" |
| 117 |
DependsOnTargets="GenerateExecutionScriptsInternal" /> |
| 118 |
|
| 119 |
<Target Name="CopyNativeProjectBinaries"> |
| 120 |
<ItemGroup> |
| 121 |
<NativeProjectBinaries Include="$(NativeProjectOutputFolder)\**\*.*" /> |
| 122 |
</ItemGroup> |
| 123 |
|
| 124 |
<Error Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once" |
| 125 |
Condition="'@(NativeProjectBinaries)' == ''" /> |
| 126 |
|
| 127 |
<Copy |
| 128 |
SourceFiles="@(NativeProjectBinaries)" |
| 129 |
DestinationFiles="@(NativeProjectBinaries -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')" |
| 130 |
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" |
| 131 |
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" |
| 132 |
Retries="$(CopyRetryCount)" |
| 133 |
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" |
| 134 |
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"> |
| 135 |
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" /> |
| 136 |
</Copy> |
| 137 |
</Target> |
| 138 |
|
| 139 |
<Target Name="ResolveCmakeNativeProjectReference" |
| 140 |
Condition="'@(ProjectReference)' != ''" |
| 141 |
BeforeTargets="BeforeResolveReferences;BeforeClean" > |
| 142 |
<ItemGroup> |
| 143 |
<NativeProjectReference Include="%(ProjectReference.Identity)" Condition="$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) == 'CMAKELISTS'" /> |
| 144 |
<ProjectReference Remove="%(NativeProjectReference.Identity)" /> |
| 145 |
<NativeProjectReferenceNormalized Include="@(NativeProjectReference -> '%(FullPath)')" /> |
| 146 |
</ItemGroup> |
| 147 |
</Target> |
| 148 |
|
| 149 |
<Target Name="ConsolidateNativeProjectReference" |
| 150 |
Condition="'@(NativeProjectReferenceNormalized)' != ''" |
| 151 |
BeforeTargets="Build" > |
| 152 |
<ItemGroup> |
| 153 |
<NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))$(Configuration)\"/> |
| 154 |
</ItemGroup> |
| 155 |
|
| 156 |
<Message Text= "Full native project references are :%(NativeProjectReferenceNormalized.Identity)" /> |
| 157 |
<Message Text= "Native binaries will be copied from :%(NativeProjectOutputFoldersToCopy.Identity)" /> |
| 158 |
<MSBuild Projects="$(MSBuildProjectFile)" Targets="CopyNativeProjectBinaries" Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity)" Condition="'@(NativeProjectReference)' != ''" /> |
| 159 |
|
| 160 |
</Target> |
| 161 |
|
| 162 |
<PropertyGroup> |
| 163 |
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);ResetReferenceCopyLocalPaths</PrepareForRunDependsOn> |
| 164 |
</PropertyGroup> |
| 165 |
|
| 166 |
<Target Name="ResetReferenceCopyLocalPaths" |
| 167 |
Condition="'@(ReferenceCopyLocalPaths)' != ''" |
| 168 |
BeforeTargets="_CopyFilesMarkedCopyLocal"> |
| 169 |
<ItemGroup> |
| 170 |
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.CopyLocal)' != 'true'"/> |
| 171 |
</ItemGroup> |
| 172 |
</Target> |
| 173 |
|
| 174 |
</Project> |