Skip to content
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

Adopt Microsoft.Build.Traversal for skipping projects when building the solution #479

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Directory.Solution.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.Build.Traversal" />
</Project>
26 changes: 3 additions & 23 deletions Directory.Solution.targets
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
<Project InitialTargets="RemoveProjectsToSkip">
<!--
RemoveProjectsToSkip removes projects from the solution if they can't be built. It determines
this by calling the ShouldSkipProject target for each project so it can indicate if a project
cannot be built and why.
-->
<Target Name="RemoveProjectsToSkip">
<MSBuild BuildInParallel="True"
Properties="BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath);"
SkipNonexistentProjects="%(ProjectReference.SkipNonexistentProjects)"
Projects="@(ProjectReference)"
Targets="ShouldSkipProject">
<Output TaskParameter="TargetOutputs"
ItemName="ProjectToSkip" />
</MSBuild>
<ItemGroup>
<ProjectReference Remove="@(ProjectToSkip)" />
</ItemGroup>
<Message Text="Skipping project &quot;%(ProjectToSkip.Identity)&quot;. %(ProjectToSkip.Message)"
Condition="@(ProjectToSkip->Count()) > 0 And '$(MSBuildRestoreSessionId)' == ''"
Importance="High" />
</Target>

<Project>
<PropertyGroup>
<!-- The target framework 'net5.0' is out of support and will not receive security updates in the future. -->
<CheckEolTargetFramework Condition="'$(TargetFramework)' == 'net5.0'">false</CheckEolTargetFramework>
</PropertyGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.Build.Traversal" />
</Project>
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"version": "7.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "4.0.0"
}
}