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

Refactor build traversal #15093

Merged
merged 2 commits into from
Jan 12, 2017
Merged

Refactor build traversal #15093

merged 2 commits into from
Jan 12, 2017

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Jan 11, 2017

Change contract of cross-project target to return configuration rather
than trying to construct a project item. This preserves the metadata of
the original Project/ProjectReference. When the MSBuild task creates
the TargetOutputs it will copy all the original metadata from the
Project items and create the OriginalItemSpec metadata. From this
we can simply transform back to a Project/ProjectReference and prepend
Configuration to the AdditionalProperties. This fixes a case where
projects were setting AdditionalProperties and we were squashing it.

To make it clearer how this worked I made the targets only return a
property so that we don't accidentally squash any metadata set on the
project.

I found that we were never using the DetermineProjectsConfiguration
target so I deleted it.

I've also cleaned up the targets to make things a bit more consistent
and added comments.

</Target>

<!-- The initial shaking target for trimming down applicable projects for specified vertical -->
<Target Name="DetermineProjectsConfiguration"
Copy link
Member

Choose a reason for hiding this comment

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

We really weren't using this target? That's surprising.

Copy link
Member

@chcosta chcosta Jan 11, 2017

Choose a reason for hiding this comment

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

Oh, it was being used, but after your refactors, it is now handled by AnnotateAndFilterProjects

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, you're right. I'll fix up that commit message. I think I got half way through and realized it was no longer needed.

chcosta
chcosta previously approved these changes Jan 11, 2017
Copy link
Member

@chcosta chcosta left a comment

Choose a reason for hiding this comment

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

Approved once the binclash stuff gets fixed

Change contract of cross-project target to return configuration rather
than trying to construct a project item.  This preserves the metadata of
the original Project/ProjectReference.  When the MSBuild task creates
the TargetOutputs it will copy all the original metadata from the
Project items and create the OriginalItemSpec metadata.  From this
we can simply transform back to a Project/ProjectReference and prepend
Configuration to the AdditionalProperties.  This fixes a case where
projects were setting AdditionalProperties and we were squashing it.

This exposed an issue in traversal where we were still setting TestTFM
(previously this was squashed, only with other AdditionalProperties).

To make it clearer how this worked I made the targets only return a
property so that we don't accidentally squash any metadata set on the
project.

I've also cleaned up the targets to make things a bit more consistent
and added comments.
This was regressed by 8d70b2c.
</Project>

<!-- Include all projects which have TestTFM from the supported set -->
<ProjectsToTest Include="@(Project)" Condition="'%(Project.Extension)'=='.csproj' And $([System.String]::new('%(Project.Identity)').Contains('.Tests'))">
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously we were only testing projects that ended with "tests" but I don't think it makes sense to filter this in multiple places. Let just let the builds file define the set of projects. I fixed the one case that wasn't working, RemoteExecutorConsoleApp: it was failing because we hardcoded .dll as the test extension. I now use TargetFileName. This will run xunit against the assembly which is a noop since it contains no tests. If we want to bring back this filtering let me know. /cc @weshaggard @mellinoe @joperezr

Copy link
Member

Choose a reason for hiding this comment

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

Just as an FYI since it is related, I recently changed (in dev/eng) the way we calculate the property for IsTestProject to instead check if the project has a tests folder in it's path, and that is what we are using today to determine which projects to test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I understand that, it still gets a false-positive for RemoteExecutorConsoleApp since that is src/Common/tests/System/Diagnostics/RemoteExecutorConsoleApp/RemoteExecutorConsoleApp.csproj.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is causing a lot more than just RemoteExecutorConsoleApp to "run" now (about 20 more assemblies based on my primitive ctrl-F searching), which I don't think is desirable. Before, the only assemblies we were unnecessarily running were things like "Performance" or "Stress" test assemblies, which technically do have test cases but are filtered via Xunit traits.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, don't you think we should filter those from Tests.builds rather than just filtering them from test execution.

Copy link
Member Author

@ericstj ericstj Jan 12, 2017

Choose a reason for hiding this comment

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

Or at least in one place rather than a side effect of many conditions in different places?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I understand the idea; we should move the logic from here into tests.builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ericstj
Copy link
Member Author

ericstj commented Jan 12, 2017

@dotnet-bot test Innerloop Ubuntu14.04 Debug Build and Test

@ericstj ericstj merged commit f3e8043 into dotnet:dev/eng Jan 12, 2017
<!-- Runs during traversal to select which projects and configurations of those projects to build -->
<Target Name="AnnotateAndFilterProjects"
BeforeTargets="BuildAllProjects;TestAllProjects"
Condition="!$(MSBuildProjectFullPath.EndsWith('.proj'))">
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this condition. Don't you want this to work on proj files as well?

Copy link
Member

Choose a reason for hiding this comment

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

I'd assume that Eric carried this over from the previous version. The only ".proj" file in the traversal at the time was build.proj and we didn't want to annotate / trim it. I'd think that it's now safe to remove that condition given other change recently.


<ItemGroup>
<_Configuration Condition="'$(BuildConfigurations)' == ''" Include="$(BuildConfiguration)" />
<!-- transform back to project -->
<ProjectWithConfiguration Include="@(_ProjectBestConfigurations->'%(OriginalItemSpec)')">
Copy link
Member

Choose a reason for hiding this comment

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

Where does the filtering occur?

</ItemGroup>
</Target>

<!-- TestAllProjects will run all tests according to TestTFM value we are filtering with -->
<Target Name="TestAllProjects"
AfterTargets="BuildAllProjects"
Condition="$(MSBuildProjectName.EndsWith('tests'))">
Copy link
Member

Choose a reason for hiding this comment

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

@mellinoe we should make this conditions consistent with what do in tests.builds. I assume that tests.builds is the only project we have now that matches this pattern from a traversal prospective.

@karelz karelz modified the milestone: 2.0.0 Jan 21, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants