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

Sdk test projects #19044

Merged
merged 19 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4140407
Only include Build.Common.targets when using buildtools
chsienki Jun 20, 2018
76761ac
Move some dir.targets into a diffent file so we can exclude them for …
chsienki Jun 20, 2018
607e202
Add Directory.Build.{targets, props} that redirect to dirs.{props, ta…
chsienki Jun 20, 2018
d73cbbe
Rename nosdk targets file, and import it when neccesary
chsienki Jun 27, 2018
c67eed2
Remove code task factory: generate the param list using msbuild synta…
chsienki Jul 2, 2018
268daa3
Force tests to have .exe extension rather than dll when they are exec…
chsienki Jul 2, 2018
f21f691
Fix dir.targets build imports so that we correctly include buildtools…
chsienki Jul 2, 2018
b4eaddb
Always include the nobuild targets if we're a run only project
chsienki Jul 2, 2018
78c81c3
Remove runtime references in override.targets when referencing System…
chsienki Jul 3, 2018
c5ad714
Add comments to Directory.Build.props,targets to explain usage
chsienki Jul 5, 2018
c7b6171
Split out nobuild and runonlybuild into two targets files to make the…
chsienki Jul 5, 2018
095cbc2
Rename runonlybuild.targets
chsienki Jul 5, 2018
da2da0d
Fix for SDK projects referencing system.private.corelib
chsienki Jul 6, 2018
d126d93
Fix build for vs2015
chsienki Jul 10, 2018
d36ca7d
Add dummy directory.build.props/targets to common folder to prevent t…
chsienki Jul 11, 2018
99e828a
Bring in sdkprops if the project is an sdk project
chsienki Jul 13, 2018
740db6d
Build sdk projects as netcoreapp3.0
chsienki Jul 16, 2018
17fbebd
Change the way we fixup references for system.private.corlib referenc…
chsienki Jul 16, 2018
6ff88b7
Pass the myget feed to the wrapper restore directly, rather than rely…
chsienki Jul 19, 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
2 changes: 1 addition & 1 deletion build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 5 additions & 1 deletion tests/dir.sdkbuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
7 changes: 7 additions & 0 deletions tests/override.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/runtest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ $(_XunitEpilog)

<PropertyGroup>
<OutputPath>$(XUnitTestBinBase)\$(CategoryWithSlash)</OutputPath>
</PropertyGroup>
<RuntimeFrameworkVersion>$(MicrosoftNETCoreRuntimeCoreCLRPackageVersion)</RuntimeFrameworkVersion>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />

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
Original file line number Diff line number Diff line change
@@ -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" />
Expand Down
8 changes: 8 additions & 0 deletions tests/src/Common/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -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>
8 changes: 8 additions & 0 deletions tests/src/Common/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -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>
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>
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 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<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 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)" />
Copy link
Member

Choose a reason for hiding this comment

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

I don't remember the default behavior of this, but does the MakeDir task consider a directory that already exists an error?

Copy link
Author

Choose a reason for hiding this comment

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

It continues if it already exists: the docs aren't clear, but looking at the code you can see it just does nothing if it's already there.

This is actually moved code from before, so the behavior should stay the same as previously.

</Target>

</Project>