Skip to content

Commit 775aefa

Browse files
committed
Unify PackageReferences checks
We were opt'ing CPS projects out of CpsProjectReferenceProjectProvider based on whether that had TargetFramework or TargetFrameworks properties, both are which are .NET-SDK specific. C++/MSIX deployment and other custom projects don't have these properties.
1 parent 9fa9c68 commit 775aefa

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/CpsPackageReferenceProjectProvider.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ public async Task<NuGetProject> TryCreateNuGetProjectAsync(
7474
return null;
7575
}
7676

77-
// Check if the project is not CPS capable or if it is CPS capable then it does not have TargetFramework(s), if so then return false
78-
if (!VsHierarchyUtility.IsCPSCapabilityComplaint(hierarchy))
77+
// Check if the project is not CPS capable or if it is CPS capable that its opt'd in PackageReferences
78+
if (!VsHierarchyUtility.IsCPSCapabilityComplaint(hierarchy) &&
79+
!VsHierarchyUtility.IsProjectCapabilityCompliant(hierarchy))
7980
{
8081
return null;
8182
}
@@ -84,20 +85,13 @@ public async Task<NuGetProject> TryCreateNuGetProjectAsync(
8485

8586
// read MSBuild property RestoreProjectStyle, TargetFramework, and TargetFrameworks
8687
var restoreProjectStyle = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.RestoreProjectStyle);
87-
var targetFramework = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.TargetFramework);
88-
var targetFrameworks = await buildProperties.GetPropertyValueAsync(ProjectBuildProperties.TargetFrameworks);
8988

9089
// check for RestoreProjectStyle property is set and if not set to PackageReference then return false
9190
if (!(string.IsNullOrEmpty(restoreProjectStyle) ||
9291
restoreProjectStyle.Equals(PackageReference, StringComparison.OrdinalIgnoreCase)))
9392
{
9493
return null;
9594
}
96-
// check whether TargetFramework or TargetFrameworks property is set, else return false
97-
else if (string.IsNullOrEmpty(targetFramework) && string.IsNullOrEmpty(targetFrameworks))
98-
{
99-
return null;
100-
}
10195

10296
var fullProjectPath = vsProject.FullProjectPath;
10397
var unconfiguredProject = GetUnconfiguredProject(vsProject.Project);

0 commit comments

Comments
 (0)