Skip to content

Commit 611d422

Browse files
committed
Cleanup usages of IsTestProject
1 parent 80b4384 commit 611d422

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Copyright (c) .NET Foundation. All rights reserved.
103103
<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == ''">
104104
<UseCurrentRuntimeIdentifier Condition="
105105
'$(RuntimeIdentifier)' == '' and
106-
'$(_IsExecutable)' == 'true' and '$(IsTestProject)' != 'true' and
106+
'$(_IsExecutable)' == 'true' and
107107
'$(IsRidAgnostic)' != 'true' and
108108
'$(PackAsTool)' != true and
109109
(

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Copyright (c) .NET Foundation. All rights reserved.
115115
<!-- Set the IsRidAgnostic property if this project should NOT accept global RuntimeIdentifier and SelfContained
116116
property values from referencing projects. -->
117117
<PropertyGroup Condition="'$(IsRidAgnostic)' == ''">
118-
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true' And '$(IsTestProject)' != 'true') Or
118+
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true') Or
119119
'$(RuntimeIdentifier)' != '' Or
120120
'$(RuntimeIdentifiers)' != ''">false</IsRidAgnostic>
121121
<IsRidAgnostic Condition="'$(IsRidAgnostic)' == ''">true</IsRidAgnostic>
@@ -1292,27 +1292,28 @@ Copyright (c) .NET Foundation. All rights reserved.
12921292
<ShouldBeValidatedAsExecutableReference>false</ShouldBeValidatedAsExecutableReference>
12931293
</PropertyGroup>
12941294

1295-
<PropertyGroup Condition="'$(IsTestProject)' == 'true' And '$(ValidateExecutableReferencesMatchSelfContained)' == ''">
1296-
<!-- Don't generate an error if a test project references a self-contained Exe. Test projects
1297-
use an OutputType of Exe but will usually call APIs in a referenced Exe rather than try
1298-
to run it. -->
1299-
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
1300-
</PropertyGroup>
1301-
1302-
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
1303-
<!-- Don't generate an error if an Exe project references a test project. -->
1304-
<ShouldBeValidatedAsExecutableReference>false</ShouldBeValidatedAsExecutableReference>
1305-
</PropertyGroup>
1306-
1307-
13081295
<UsingTask TaskName="ValidateExecutableReferences" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
13091296

13101297
<PropertyGroup>
13111298
<_UseAttributeForTargetFrameworkInfoPropertyNames Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), '17.0'))">true</_UseAttributeForTargetFrameworkInfoPropertyNames>
13121299
</PropertyGroup>
13131300

1301+
<Target Name="_CalculateIsVSTest">
1302+
<PropertyGroup>
1303+
<_IsVSTest Condition="'$(IsTestProject)' == 'true' and '$(IsTestingPlatformApplication)' != 'true'">true</_IsVSTest>
1304+
<_IsVSTest Condition="'$(_IsVSTest)' == ''">false</_IsVSTest>
1305+
1306+
<!-- Don't generate an error if an Exe project references a test project. -->
1307+
<ShouldBeValidatedAsExecutableReference Condition="'$(_IsVSTest)' == 'true'">false</ShouldBeValidatedAsExecutableReference>
1308+
1309+
<!-- Don't generate an error if a test project references a self-contained Exe. Test projects
1310+
use an OutputType of Exe but will usually call APIs in a referenced Exe rather than try
1311+
to run it. -->
1312+
<ValidateExecutableReferencesMatchSelfContained Condition="'$(_IsVSTest)' == 'true' And '$(ValidateExecutableReferencesMatchSelfContained)' == ''">false</ValidateExecutableReferencesMatchSelfContained>
1313+
</PropertyGroup>
1314+
</Target>
1315+
13141316
<Target Name="ValidateExecutableReferences"
1315-
AfterTargets="_GetProjectReferenceTargetFrameworkProperties"
13161317
Condition="'$(ValidateExecutableReferencesMatchSelfContained)' != 'false'">
13171318

13181319
<ValidateExecutableReferences
@@ -1322,6 +1323,12 @@ Copyright (c) .NET Foundation. All rights reserved.
13221323
UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)"/>
13231324
</Target>
13241325

1326+
<Target Name="ValidateExecutableReferencesCore"
1327+
DependsOnTargets="_CalculateIsVSTest;ValidateExecutableReferences"
1328+
AfterTargets="_GetProjectReferenceTargetFrameworkProperties">
1329+
1330+
</Target>
1331+
13251332
<!--
13261333
============================================================
13271334
Command Line Configuration Validation

0 commit comments

Comments
 (0)