Skip to content

Commit 0071d6a

Browse files
committed
Skip checking for packages.config in SDK-style projects
1 parent 14b7672 commit 0071d6a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.targets

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,19 @@
102102
</ItemGroup>
103103
</Target>
104104

105-
<!-- Remove the analyzer if packages.config is used -->
105+
<!--
106+
Inform the user if packages.config is used (as the analyzers and the source generators
107+
won't work at all). Since packages.config can only be used with legacy-style projects,
108+
the entire package can be skipped if an SDK-style project is used.
109+
-->
106110
<Target Name="MVVMToolkitWarnForPackagesConfigUse"
107111
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
108-
DependsOnTargets="MVVMToolkitGatherAnalyzers">
112+
Condition="'$(UsingMicrosoftNetSDK)' != 'true'">
109113

110114
<!--
111115
Check whether packages are being restored via packages.config, by reading the associated MSBuild property.
112116
This happens when either the project style is using packages.config, or when explicitly requested.
113-
See https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#restoring-packagereference-and-packagesconfig-projects-with-msbuild.
117+
See https://learn.microsoft.com/nuget/reference/msbuild-targets#restoring-packagereference-and-packagesconfig-projects-with-msbuild.
114118
-->
115119
<PropertyGroup>
116120
<MVVMToolkitIsTargetProjectUsingPackagesConfig Condition ="'$(RestorePackagesConfig)' == 'true' OR '$(RestoreProjectStyle)' == 'PackagesConfig'">true</MVVMToolkitIsTargetProjectUsingPackagesConfig>
@@ -120,6 +124,8 @@
120124
If no packages.config properties are set, also try to manually find the packages.config file.
121125
This will be in the @(None) elements, if present. Doing so makes sure this works in builds as
122126
well, since the implicit targets populating the properties above only run when restoring.
127+
Since the packages.config file will always be in the root of the project, if present, we will
128+
match with the full item spec (see https://learn.microsoft.com/nuget/reference/packages-config).
123129
-->
124130
<FindInList ItemSpecToFind="packages.config"
125131
List="@(None)"

0 commit comments

Comments
 (0)