diff options
author | Chris Sienkiewicz <chsienki@microsoft.com> | 2018-07-25 11:13:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 11:13:27 -0700 |
commit | eddc1a621b66d63ac9feda289f08fc0e9f67f850 (patch) | |
tree | 6fc79a1d2daab52f4e70ef85ab1d068fe064295c /tests | |
parent | 2b92e13d9c015de34b12487131932410148ffb80 (diff) | |
download | coreclr-eddc1a621b66d63ac9feda289f08fc0e9f67f850.tar.gz coreclr-eddc1a621b66d63ac9feda289f08fc0e9f67f850.tar.bz2 coreclr-eddc1a621b66d63ac9feda289f08fc0e9f67f850.zip |
Sdk test projects (#19044)
Change the associated targets and props files in the test directory to allow the test csproj's to be built as SDK style projects alongside traditional style projects.
Remove CodeTaskFactory:
- Allows the projects to be built using the core version of msbuild/dotnet build
- Converted to using msbuild property expansion instead
Add directory.build.{props,targets}:
- Currently we just import the dirs.props and targets, but means SDK style projects don't need to explicitly include these files
- We probably want to move all projects over to using these in the future, but this keeps the changes smaller for now
Specific code for SDK projects:
- There are a several changes required to build an SDK project. This change guards them behind conditionals so that only the new style projects see them. When we get to the point that there are only new projects, we can remove the guards (probably at the same time as ditching the dir.props)
Reordered build targets:
- Because SDK projects implicitly import the build targets, we can no longer re-define the build targets unconditionally knowing they will likely be overwritten.
- Instead we move the overwritten targets to separate files, and include these conditionally based on properties. In this way there is always a build defined for SDK projects, which can then be overwritten to do nothing as needed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dir.props | 2 | ||||
-rw-r--r-- | tests/dir.sdkbuild.props | 6 | ||||
-rw-r--r-- | tests/override.targets | 7 | ||||
-rw-r--r-- | tests/runtest.proj | 3 | ||||
-rw-r--r-- | tests/src/CLRTest.Execute.Batch.targets | 7 | ||||
-rw-r--r-- | tests/src/CLRTest.Execute.targets | 38 | ||||
-rw-r--r-- | tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj | 1 | ||||
-rw-r--r-- | tests/src/Common/Directory.Build.props | 8 | ||||
-rw-r--r-- | tests/src/Common/Directory.Build.targets | 8 | ||||
-rw-r--r-- | tests/src/Directory.Build.props | 6 | ||||
-rw-r--r-- | tests/src/Directory.Build.targets | 6 | ||||
-rw-r--r-- | tests/src/dir.targets | 31 | ||||
-rw-r--r-- | tests/src/nobuild.targets | 8 | ||||
-rw-r--r-- | tests/src/runonly.targets | 13 |
14 files changed, 83 insertions, 61 deletions
diff --git a/tests/dir.props b/tests/dir.props index 5b0713610d..ffae126bb8 100644 --- a/tests/dir.props +++ b/tests/dir.props @@ -8,6 +8,8 @@ <OsEnvironment Condition="'$(OsEnvironment)'==''">$(OS)</OsEnvironment> </PropertyGroup> + <Import Project="dir.sdkbuild.props" Condition="'$(UsingMicrosoftNETSdk)' == 'true'" /> + <!-- Build Tools Versions --> <PropertyGroup> <RoslynVersion>1.0.0-rc3-20150510-01</RoslynVersion> diff --git a/tests/dir.sdkbuild.props b/tests/dir.sdkbuild.props index b5a0fdd076..486e882504 100644 --- a/tests/dir.sdkbuild.props +++ b/tests/dir.sdkbuild.props @@ -6,9 +6,13 @@ and buildtools projects should go in dir.common.props. --> <PropertyGroup> - <TargetFramework>netcoreapp2.0</TargetFramework> + <TargetFramework>netcoreapp3.0</TargetFramework> + <RuntimeFrameworkVersion>$(MicrosoftNETCoreRuntimeCoreCLRPackageVersion)</RuntimeFrameworkVersion> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> + + <!-- Force the CLI to allow us to target higher netcoreapp than it may know about --> + <NETCoreAppMaximumVersion>99.0</NETCoreAppMaximumVersion> </PropertyGroup> </Project> diff --git a/tests/override.targets b/tests/override.targets index d4c07a0f00..a713489fc3 100644 --- a/tests/override.targets +++ b/tests/override.targets @@ -18,6 +18,13 @@ </ItemGroup> </Target> + <!-- Remove package references when referencing System.Private.CoreLib from SDK style project --> + <Target Name="CleanResolvedCompileFileDefinitions" AfterTargets="ResolvePackageAssets" Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' == 'true'" > + <ItemGroup> + <ResolvedCompileFileDefinitions Remove="@(ResolvedCompileFileDefinitions)" /> + </ItemGroup> + </Target> + <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'"> <!-- Allow this project to setup the default target frameworks. Note this depends on the targeting packs that VS diff --git a/tests/runtest.proj b/tests/runtest.proj index df5ff2d422..1260a00bdd 100644 --- a/tests/runtest.proj +++ b/tests/runtest.proj @@ -80,7 +80,8 @@ $(_XunitEpilog) <PropertyGroup> <OutputPath>$(XUnitTestBinBase)\$(CategoryWithSlash)</OutputPath> - </PropertyGroup> + <RuntimeFrameworkVersion>$(MicrosoftNETCoreRuntimeCoreCLRPackageVersion)</RuntimeFrameworkVersion> + </PropertyGroup> <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" /> diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index 0a6fd439a3..70cede618f 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -299,11 +299,6 @@ set CLRTestExitCode=!ERRORLEVEL! <!-- Raise an error if any value in _RequiredProperties is missing --> <Error Condition=" '%(_RequiredProperties.Value)'=='' " Text="Missing required test property [%(_RequiredProperties.Identity)]. Something isn't plumbed through correctly. Contact $(_CLRTestBuildSystemOwner)." /> - <!-- TODO: this is weird. Consider eliminating it. --> - <GenerateParamList ArgumentItems="@(BatchCLRTestExecutionScriptArgument)"> - <Output TaskParameter="ParamList" PropertyName="_CLRTestParamList"/> - </GenerateParamList> - <PropertyGroup> <!-- This generates the script portion to parse all of the command line arguments. @@ -339,7 +334,7 @@ goto ArgsDone :USAGE ECHO.Usage -ECHO %0 $(_CLRTestParamList) +ECHO %0 @(BatchCLRTestExecutionScriptArgument -> '[-%(Identity) %(ParamName)]', ' ') ECHO. ECHO - OPTIONS - @(BatchCLRTestExecutionScriptArgument -> 'ECHO -%(Identity) %(ParamName) diff --git a/tests/src/CLRTest.Execute.targets b/tests/src/CLRTest.Execute.targets index 50860ea529..ff0becbf25 100644 --- a/tests/src/CLRTest.Execute.targets +++ b/tests/src/CLRTest.Execute.targets @@ -33,44 +33,6 @@ This file contains the logic for providing Execution Script generation. <HasParam>false</HasParam> </CLRTestExecutionScriptArgument> </ItemDefinitionGroup> - - <!-- - TASK: GenerateParamList - This task takes a list of CLRTestExecutionScriptArgument items and - returns a string fit for the usage help message. - example: - [-arg1 param1] [-arg2] [-arg3 param3] - --> - <UsingTask - TaskName="GenerateParamList" - TaskFactory="CodeTaskFactory" - AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> - <ParameterGroup> - <ArgumentItems ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true"/> - <ParamList ParameterType="System.String" Output="true"/> - </ParameterGroup> - <Task> - <Reference Include="System.Core"/> - <Using Namespace="System"/> - <Using Namespace="System.Linq"/> - <Code Type="Fragment" Language="cs"><![CDATA[ - Func<string, bool> parseBool = s => - { - bool value; - var success = bool.TryParse(s, out value); - if (success) - return value; - return false; - }; - var items = ArgumentItems.Select(i => new { Item=i, HasParam=parseBool(i.GetMetadata("HasParam"))}); - var noArg = items.Where(i => !i.HasParam).Select(i => new { Identity=i.Item.ItemSpec}); - var haveArg = items.Where(i => i.HasParam).Select(i => new { Identity=i.Item.ItemSpec, Name=i.Item.GetMetadata("ParamName")}); - ParamList = haveArg.Aggregate("", (s,i) => string.Format("{0} [-{1} {2}]", s, i.Identity, i.Name)) + - noArg.Aggregate("", (s,i) => string.Format("{0} [-{1}]", s, i.Identity)); - ]]> - </Code> - </Task> - </UsingTask> <!-- ******************************************************************************************* diff --git a/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj b/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj index 77629e6554..3af5fe93e9 100644 --- a/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj +++ b/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj @@ -1,5 +1,6 @@ <Project> + <Import Project="$([MSBuild]::GetPathOfFileAbove('dependencies.props', '$(MSBuildThisFileDirectory)../'))" /> <Import Project="$([MSBuild]::GetPathOfFileAbove('dir.sdkbuild.props', '$(MSBuildThisFileDirectory)../'))" /> <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" /> diff --git a/tests/src/Common/Directory.Build.props b/tests/src/Common/Directory.Build.props new file mode 100644 index 0000000000..ea5280734f --- /dev/null +++ b/tests/src/Common/Directory.Build.props @@ -0,0 +1,8 @@ +<Project> + <!-- + Common files don't take part in the root tests\src\Directory.Build.props + This file prevents them from including it as it gets included in its place + If they ever need to take part, we can conditionally include them as documented + here https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets + --> +</Project>
\ No newline at end of file diff --git a/tests/src/Common/Directory.Build.targets b/tests/src/Common/Directory.Build.targets new file mode 100644 index 0000000000..09cfd7a44e --- /dev/null +++ b/tests/src/Common/Directory.Build.targets @@ -0,0 +1,8 @@ +<Project> + <!-- + Common files don't take part in the root tests\src\Directory.Build.targets + This file prevents them from including it as it gets included in its place + If they ever need to take part, we can conditionally include them as documented + here https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets + --> +</Project>
\ No newline at end of file diff --git a/tests/src/Directory.Build.props b/tests/src/Directory.Build.props new file mode 100644 index 0000000000..d4620863f4 --- /dev/null +++ b/tests/src/Directory.Build.props @@ -0,0 +1,6 @@ +<Project> + <!-- SDK Style projects auto-magically include this file. + We include the dir.props for them here so they partake in the old + style of build without them needing to explicitly include anything --> + <Import Project="dir.props" Condition="'$(UsingMicrosoftNETSdk)' == 'true'" /> +</Project> diff --git a/tests/src/Directory.Build.targets b/tests/src/Directory.Build.targets new file mode 100644 index 0000000000..f3439a7b90 --- /dev/null +++ b/tests/src/Directory.Build.targets @@ -0,0 +1,6 @@ +<Project> + <!-- SDK Style projects auto-magically include this file. + We include the dir.targets for them here so they partake in the old + style of build without them needing to explicitly include anything --> + <Import Project="dir.targets" Condition="'$(UsingMicrosoftNETSdk)' == 'true'" /> +</Project> diff --git a/tests/src/dir.targets b/tests/src/dir.targets index e6845e0fd1..64f0d804f8 100644 --- a/tests/src/dir.targets +++ b/tests/src/dir.targets @@ -5,6 +5,11 @@ <CLRTestKind Condition="'$(CLRTestKind)' == ''">BuildAndRun</CLRTestKind> <CLRTestPriority Condition="'$(CLRTestPriority)' == ''">0</CLRTestPriority> </PropertyGroup> + + <PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'"> + <!-- 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 --> + <TargetExt Condition="'$(OutputType)' == 'Exe' and '$(TargetExt)' == '.dll'">.exe</TargetExt> + </PropertyGroup> <!-- All CLRTests need to be of a certain "kind". These kinds are enumerated below. By default all tests are BuildAndRun. This means that the build system will Build them @@ -70,27 +75,23 @@ <Import Project="..\dir.targets" /> - <Target Name="CreateManifestResourceNames" /> - <Target Name="CoreCompile" /> - - <!-- If we are a run-only, that depends on another project, this is the "Build" we use. I.e. build all dependency projects, absolutely. - --> - + <!-- Determine if this project should be built or not --> <PropertyGroup> <BuildAllProjects Condition=" '$(BuildAllProjects)' == ''">false</BuildAllProjects> <_WillCLRTestProjectBuild Condition="'$(_WillCLRTestProjectBuild)' == ''">false</_WillCLRTestProjectBuild> <_WillCLRTestProjectBuild Condition="'$(BuildAllProjects)' != true">true</_WillCLRTestProjectBuild> <_WillCLRTestProjectBuild Condition="'$(DisableProjectBuild)' != true And '$(BuildAllProjects)' == true And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'">true</_WillCLRTestProjectBuild> </PropertyGroup> - - <Target Name="Build" Condition="('$(CLRTestKind)'=='RunOnly') And '$(_WillCLRTestProjectBuild)'"> - <MSBuild Projects="@(ProjectReference)" /> - <MakeDir Condition="'$(CLRTestKind)' == 'RunOnly'" ContinueOnError="false" Directories="$(OutputPath)" /> - </Target> + + <!-- if we have determined that there is nothing to build, overwrite the build targets so that nothing happens --> + <Import Project="nobuild.targets" Condition="'$(_WillCLRTestProjectBuild)' == 'false'" /> + + <!-- RunOnly projects have a special build for dependent projects --> + <Import Project="runonly.targets" Condition="'$(CLRTestKind)' == 'RunOnly'" /> - <!-- 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 + <!-- 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 a test with a higher priority. --> - <Import Project="$(ToolsDir)Build.Common.targets" Condition="('$(CLRTestKind)'!='RunOnly') And $(_CLRTestCompilesSource) And ('$(_WillCLRTestProjectBuild)')"/> + <Import Project="$(ToolsDir)Build.Common.targets" Condition="('$(UsingMicrosoftNETSdk)' != 'true') And ('$(CLRTestKind)'!='RunOnly') And $(_CLRTestCompilesSource) And ('$(_WillCLRTestProjectBuild)')"/> <Import Project="..\override.targets" Condition="Exists('..\override.targets')"/> @@ -193,8 +194,8 @@ <ProjectAssetsFile>$(SourceDir)Common\test_dependencies\obj\project.assets.json</ProjectAssetsFile> </PropertyGroup> - <PropertyGroup Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true'"> - <ProjectAssetsFile></ProjectAssetsFile > + <PropertyGroup Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'"> + <ProjectAssetsFile></ProjectAssetsFile> </PropertyGroup> </Project> diff --git a/tests/src/nobuild.targets b/tests/src/nobuild.targets new file mode 100644 index 0000000000..491865a989 --- /dev/null +++ b/tests/src/nobuild.targets @@ -0,0 +1,8 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <Target Name="CreateManifestResourceNames" /> + <Target Name="Compile" /> + <Target Name="CoreCompile" /> + <Target Name="Build" /> + +</Project>
\ No newline at end of file diff --git a/tests/src/runonly.targets b/tests/src/runonly.targets new file mode 100644 index 0000000000..2e01bc7ec8 --- /dev/null +++ b/tests/src/runonly.targets @@ -0,0 +1,13 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <Target Name="CreateManifestResourceNames" /> + <Target Name="Compile" /> + <Target Name="CoreCompile" /> + + <!-- if this is a RunOnly project that has been scheduled to build, make the output directory and build any dependent projects --> + <Target Name="Build" Condition="('$(CLRTestKind)'=='RunOnly') And '$(_WillCLRTestProjectBuild)'"> + <MSBuild Projects="@(ProjectReference)" /> + <MakeDir ContinueOnError="false" Directories="$(OutputPath)" /> + </Target> + +</Project>
\ No newline at end of file |