-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adjust IsTestProject
hacks to not include MTP
#49085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adjusts test project conditions so that projects using the Microsoft Testing Platform (MTP) are no longer treated as standard test projects. The changes introduce a new property (_IsVSTestOnlyTestProject) and update existing conditions in the targets file to use this property.
- Introduces _IsVSTestOnlyTestProject to differentiate test projects from MTP projects.
- Updates condition checks for IsRidAgnostic, ValidateExecutableReferencesMatchSelfContained, and ShouldBeValidatedAsExecutableReference.
@@ -97,6 +97,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<_DefaultUserProfileRuntimeStorePath Condition="$([MSBuild]::IsOSPlatform(`Windows`))">$(USERPROFILE)</_DefaultUserProfileRuntimeStorePath> | |||
<_DefaultUserProfileRuntimeStorePath>$([System.IO.Path]::Combine($(_DefaultUserProfileRuntimeStorePath), '.dotnet', 'store'))</_DefaultUserProfileRuntimeStorePath> | |||
<UserProfileRuntimeStorePath Condition="'$(UserProfileRuntimeStorePath)' == ''">$(_DefaultUserProfileRuntimeStorePath)</UserProfileRuntimeStorePath> | |||
<_IsVSTestOnlyTestProject 8000 Condition="'$(IsTestProject)' == 'true' AND '$(IsTestingPlatformApplication)' != 'true'">true</_IsVSTestOnlyTestProject> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding an inline comment explaining the purpose of the new _IsVSTestOnlyTestProject property, clarifying that it excludes MTP projects from test-specific conditions.
Copilot uses AI. Check for mistakes.
@@ -114,7 +115,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<!-- Set the IsRidAgnostic property if this project should NOT accept global RuntimeIdentifier and SelfContained | |||
property values from referencing projects. --> | |||
<PropertyGroup Condition="'$(IsRidAgnostic)' == ''"> | |||
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true' And '$(IsTestProject)' != 'true') Or | |||
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true' And '$(_IsVSTestOnlyTestProject)' != 'true') Or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Review and update any nearby inline comments to ensure they accurately reflect the change from IsTestProject to _IsVSTestOnlyTestProject for non-MTP test projects.
Copilot uses AI. Check for mistakes.
@dsplaisted Can I have an eye on this PR please? Thanks! |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though if we can define _IsVSTestOnlyTestProject
only once I think that would be better.
Have you tested this? Do you think we should add automated tests? There are some existing tests for Reference Exe scenarios here: https://github.com/dotnet/sdk/blob/main/test/Microsoft.NET.Build.Tests/ReferenceExeTests.cs
@@ -97,6 +97,8 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<_DefaultUserProfileRuntimeStorePath Condition="$([MSBuild]::IsOSPlatform(`Windows`))">$(USERPROFILE)</_DefaultUserProfileRuntimeStorePath> | |||
<_DefaultUserProfileRuntimeStorePath>$([System.IO.Path]::Combine($(_DefaultUserProfileRuntimeStorePath), '.dotnet', 'store'))</_DefaultUserProfileRuntimeStorePath> | |||
<UserProfileRuntimeStorePath Condition="'$(UserProfileRuntimeStorePath)' == ''">$(_DefaultUserProfileRuntimeStorePath)</UserProfileRuntimeStorePath> | |||
<!-- This excludes MTP projects, as they are normal console apps --> | |||
<_IsVSTestOnlyTestProject Condition="'$(IsTestProject)' == 'true' AND '$(IsTestingPlatformApplication)' != 'true'">true</_IsVSTestOnlyTestProject> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this property is defined multiple times. Can you find a single place to define it? You may need to dig into the evaluation order to figure out the right place to do this.
@dsplaisted Would adding the property here be good? Or probably here can be good as well |
@Youssef1313 Looking at the ordering, I think you can leave it where you have it in Microsoft.NET.RuntimeIdentifierInference.targets, and remove it from Microsoft.NET.Sdk.targets, and that should work. |
Fixes #49063