Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Allow test projects to be SDK style #18810

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
313449f
Only include Build.Common.targets when using buildtools
chsienki Jun 20, 2018
78b00de
Move some dir.targets into a diffent file so we can exclude them for …
chsienki Jun 20, 2018
8959ebe
Add Directory.Build.{targets, props} that redirect to dirs.{props, ta…
chsienki Jun 20, 2018
bb32b49
Remove extra slash from Base[Intermediate]OutputPath on tests
chsienki Jun 22, 2018
dce8e68
Rename targetassemblyname extension to dll
chsienki Jun 27, 2018
1762942
Rename nosdk targets file, and import it when neccesary
chsienki Jun 27, 2018
251c232
Enable required properties for sdk properties at the root dirs.props
chsienki Jun 28, 2018
b17cff6
Remove code task factory: generate the param list using msbuild synta…
chsienki Jul 2, 2018
66f84de
Revert "Rename targetassemblyname extension to dll"
chsienki Jul 2, 2018
f2ae5a9
Force tests to have .exe extension rather than dll when they are exec…
chsienki Jul 2, 2018
34f6d3a
Fix dir.targets build imports so that we correctly include buildtools…
chsienki Jul 2, 2018
dbaa803
Always include the nobuild targets if we're a run only project
chsienki Jul 2, 2018
78d4089
Remove runtime references in override.targets when referencing System…
chsienki Jul 3, 2018
ed2feaf
Merge branch 'master' into sdk_projects
chsienki Jul 5, 2018
b31c3ac
Add comments to Directory.Build.props,targets to explain usage
chsienki Jul 5, 2018
d9720b5
Split out nobuild and runonlybuild into two targets files to make the…
chsienki Jul 5, 2018
34b66a4
Rename runonlybuild.targets
chsienki Jul 5, 2018
613f9a0
Fix for SDK projects referencing system.private.corelib
chsienki Jul 6, 2018
0c32d18
Initial change to allow build wrappers and runtest.py
Jun 8, 2018
23d8627
Build xunit wrappers on unix
sbomer Jun 15, 2018
2889281
Correctly generate TestEnv xplat
Jun 18, 2018
4a2f434
Build xunit wrappers using SDK
sbomer Jun 19, 2018
0be3ded
Target netcoreapp2.0 in xunit wrappers
sbomer Jun 19, 2018
0ebb165
Restore to packages directory for xunit wrappers
sbomer Jun 20, 2018
5055fd4
Move common properties out to dir.common.props
sbomer Jun 27, 2018
df7b2f3
Remove desktop-specific test wrapper csproj
sbomer Jun 27, 2018
0963074
Pass build os/arch/type and logsdir to msbuild from runtest.py
sbomer Jun 27, 2018
41c25f3
Remove xunit wrapper helper library from travernal build
sbomer Jun 28, 2018
bf93ab2
Fix parameter passing in build-test.sh
sbomer Jun 28, 2018
2cc7024
Clean up factored .props files
sbomer Jun 28, 2018
493a4b8
Undo runtest.sh changes
sbomer Jun 28, 2018
379bc34
Use latest xunit console runner everywhere
sbomer Jun 28, 2018
4ccf85e
Remove extra StaticDependency on xunit.runner.console
sbomer Jun 28, 2018
51fae78
Eliminate tests/src/dir.common.props, and rename dir.sdkbuild.props
sbomer Jun 29, 2018
9c49d85
Reintroduce dir.sdkbuild.props as a place for SDK-only props
sbomer Jun 29, 2018
db49431
Add xml namespace to dir.common.props
sbomer Jun 29, 2018
8aed5fd
Satisfy xunit analyzer
sbomer Jun 29, 2018
89ba5c1
Satisfy xunit analyzer again
sbomer Jun 29, 2018
c5860f0
Use SDK msbuild to build wrappers
sbomer Jul 3, 2018
71d0327
Remove Microsoft.CSharp.Core.targets workaround
sbomer Jul 6, 2018
96a11ef
Remove UseRoslynCompilers prop and unify roslyn import
sbomer Jul 6, 2018
98a9614
Merge branch 'unify_test_runner' of https://github.com/sbomer/coreclr…
chsienki Jul 9, 2018
98a1b2c
Merge branch 'master' of https://github.com/dotnet/coreclr into merge…
chsienki Jul 9, 2018
8814d88
Remove duplicate properties
chsienki Jul 9, 2018
3f2c0cd
Don't import dirs.props/targets in coreclr.testwrapper
chsienki Jul 9, 2018
7f61eac
Merge branch 'master' of https://github.com/dotnet/coreclr into sdk_p…
chsienki Jul 9, 2018
6111010
Fix build for vs2015
chsienki Jul 10, 2018
829c52b
Undo fix for test wrapper.
chsienki Jul 11, 2018
5280198
Add dummy directory.build.props/targets to common folder to prevent t…
chsienki Jul 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/override.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
</ItemGroup>
</Target>

<!-- Remove duplicate runtime references that occur when referencing System.Private.CoreLib from and SDK style project -->
<Target Name="RemoveRuntimeReferences"
Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' == 'true'"
AfterTargets="ResolveReferences">
<ItemGroup>
<ReferencePath Remove="@(ReferencePath)" Condition="$([System.String]::new('%(ReferencePath.HintPath)').EndsWith('System.Runtime.dll')) or $([System.String]::new('%(ReferencePath.HintPath)').EndsWith('System.Collections.dll'))" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these getting duplicated? Wouldn't it be better to try and eliminate the duplication instead of fixing it after the fact?

</ItemGroup>
</Target>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<!--
Allow this project to setup the default target frameworks. Note this depends on the targeting packs that VS
Expand Down
7 changes: 1 addition & 6 deletions tests/src/CLRTest.Execute.Batch.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -339,7 +334,7 @@ goto ArgsDone

:USAGE
ECHO.Usage
ECHO %0 $(_CLRTestParamList)
ECHO %0 @(BatchCLRTestExecutionScriptArgument -> '[-%(Identity) %(ParamName)]', ' ')
ECHO.
ECHO - OPTIONS -
@(BatchCLRTestExecutionScriptArgument -> 'ECHO -%(Identity) %(ParamName)
Expand Down
38 changes: 0 additions & 38 deletions tests/src/CLRTest.Execute.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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>

<!--
*******************************************************************************************
Expand Down
6 changes: 6 additions & 0 deletions tests/src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 6 additions & 0 deletions tests/src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions tests/src/dir.common.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
<!-- Setup the default output and intermediate paths -->
<PropertyGroup>
<OSPlatformConfig>$(BuildOS).$(Platform).$(Configuration)</OSPlatformConfig>
<BaseOutputPath>$(ProjectDir)\..\bin\tests</BaseOutputPath>
<BaseOutputPath>$(ProjectDir)..\bin\tests</BaseOutputPath>
<BaseOutputPath Condition="'$(__TestRootDir)' != ''">$(__TestRootDir)</BaseOutputPath>
<BaseOutputPathWithConfig>$(BaseOutputPath)\$(OSPlatformConfig)\</BaseOutputPathWithConfig>
<BinDir>$(BaseOutputPathWithConfig)</BinDir>
<BaseIntermediateOutputPath>$(ProjectDir)\..\bin\tests\obj\$(OSPlatformConfig)\Managed\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath>$(ProjectDir)..\bin\tests\obj\$(OSPlatformConfig)\Managed\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="'$(__ManagedTestIntermediatesDir)' != ''">$(__ManagedTestIntermediatesDir)\</BaseIntermediateOutputPath>
<__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\obj\$(BuildOS).$(Platform).$(Configuration)\Native\))</__NativeTestIntermediatesDir>
<BuildProjectRelativeDir>$(MSBuildProjectName)\</BuildProjectRelativeDir>
Expand Down
6 changes: 6 additions & 0 deletions tests/src/dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<TestWrappersPackagesConfigFileDirectory>$(MSBuildThisFileDirectory)TestWrappersConfig\</TestWrappersPackagesConfigFileDirectory>
<AssemblyKey>Test</AssemblyKey>
</PropertyGroup>

<PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<!-- Expose the target OS in a more convenient fashion -->
<PropertyGroup>
Expand Down
31 changes: 16 additions & 15 deletions tests/src/dir.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)' &lt;= '$(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')"/>
Expand Down Expand Up @@ -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>
8 changes: 8 additions & 0 deletions tests/src/nobuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<Target Name="CreateManifestResourceNames" />
<Target Name="Compile" />
<Target Name="CoreCompile" />
<Target Name="Build" />

</Project>
13 changes: 13 additions & 0 deletions tests/src/runonly.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<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>