From eddc1a621b66d63ac9feda289f08fc0e9f67f850 Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Wed, 25 Jul 2018 11:13:27 -0700 Subject: [PATCH] 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. --- build-test.cmd | 2 +- tests/dir.props | 2 + tests/dir.sdkbuild.props | 6 ++- tests/override.targets | 7 ++++ tests/runtest.proj | 3 +- tests/src/CLRTest.Execute.Batch.targets | 7 +--- tests/src/CLRTest.Execute.targets | 38 ------------------- .../Coreclr.TestWrapper.csproj | 1 + tests/src/Common/Directory.Build.props | 8 ++++ tests/src/Common/Directory.Build.targets | 8 ++++ tests/src/Directory.Build.props | 6 +++ tests/src/Directory.Build.targets | 6 +++ tests/src/dir.targets | 31 +++++++-------- tests/src/nobuild.targets | 8 ++++ tests/src/runonly.targets | 13 +++++++ 15 files changed, 84 insertions(+), 62 deletions(-) create mode 100644 tests/src/Common/Directory.Build.props create mode 100644 tests/src/Common/Directory.Build.targets create mode 100644 tests/src/Directory.Build.props create mode 100644 tests/src/Directory.Build.targets create mode 100644 tests/src/nobuild.targets create mode 100644 tests/src/runonly.targets diff --git a/build-test.cmd b/build-test.cmd index 31c5ad385795..a688e5952803 100644 --- a/build-test.cmd +++ b/build-test.cmd @@ -440,7 +440,7 @@ set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well. -call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs% +call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo Xunit Wrapper build failed exit /b 1 diff --git a/tests/dir.props b/tests/dir.props index 5b0713610d98..ffae126bb8de 100644 --- a/tests/dir.props +++ b/tests/dir.props @@ -8,6 +8,8 @@ $(OS) + + 1.0.0-rc3-20150510-01 diff --git a/tests/dir.sdkbuild.props b/tests/dir.sdkbuild.props index b5a0fdd07662..486e88250485 100644 --- a/tests/dir.sdkbuild.props +++ b/tests/dir.sdkbuild.props @@ -6,9 +6,13 @@ and buildtools projects should go in dir.common.props. --> - netcoreapp2.0 + netcoreapp3.0 + $(MicrosoftNETCoreRuntimeCoreCLRPackageVersion) false false + + + 99.0 diff --git a/tests/override.targets b/tests/override.targets index d4c07a0f00bf..a713489fc36c 100644 --- a/tests/override.targets +++ b/tests/override.targets @@ -18,6 +18,13 @@ + + + + + + + - - - - - - - - - - - - - - - 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)); - ]]> - - - + \ 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 000000000000..09cfd7a44e10 --- /dev/null +++ b/tests/src/Common/Directory.Build.targets @@ -0,0 +1,8 @@ + + + \ 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 000000000000..d4620863f4df --- /dev/null +++ b/tests/src/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/tests/src/Directory.Build.targets b/tests/src/Directory.Build.targets new file mode 100644 index 000000000000..f3439a7b9026 --- /dev/null +++ b/tests/src/Directory.Build.targets @@ -0,0 +1,6 @@ + + + + diff --git a/tests/src/dir.targets b/tests/src/dir.targets index e6845e0fd173..64f0d804f85d 100644 --- a/tests/src/dir.targets +++ b/tests/src/dir.targets @@ -5,6 +5,11 @@ BuildAndRun 0 + + + + .exe + - + false <_WillCLRTestProjectBuild Condition="'$(_WillCLRTestProjectBuild)' == ''">false <_WillCLRTestProjectBuild Condition="'$(BuildAllProjects)' != true">true <_WillCLRTestProjectBuild Condition="'$(DisableProjectBuild)' != true And '$(BuildAllProjects)' == true And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'">true - - - - - + + + + + + - - + @@ -193,8 +194,8 @@ $(SourceDir)Common\test_dependencies\obj\project.assets.json - - + + diff --git a/tests/src/nobuild.targets b/tests/src/nobuild.targets new file mode 100644 index 000000000000..491865a98965 --- /dev/null +++ b/tests/src/nobuild.targets @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tests/src/runonly.targets b/tests/src/runonly.targets new file mode 100644 index 000000000000..2e01bc7ec8e8 --- /dev/null +++ b/tests/src/runonly.targets @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file