Skip to content

Scope analyzer PackageReferences to SDK-style projects only in Directory.Build.props#60

Merged
Chris-Wolfgang merged 2 commits intorepofrom
copilot/sub-pr-58
Mar 9, 2026
Merged

Scope analyzer PackageReferences to SDK-style projects only in Directory.Build.props#60
Chris-Wolfgang merged 2 commits intorepofrom
copilot/sub-pr-58

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

Directory.Build.props was injecting analyzer PackageReference items into all projects globally, including legacy non-SDK .csproj files in examples/Net4.8 that use packages.config, breaking restore behavior for those projects.

Description

Added Condition="'$(UsingMicrosoftNETSdk)' == 'true'" to both ItemGroup blocks so analyzer references are only applied to SDK-style projects:

<ItemGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
  <AdditionalFiles Include="$(MSBuildThisFileDirectory)BannedSymbols.txt" />
</ItemGroup>

<ItemGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
  <PackageReference Include="Roslynator.Analyzers" ... />
  <!-- remaining analyzer references -->
</ItemGroup>

Legacy packages.config projects (e.g., examples/Net4.8/**) are unaffected.

Type of change

  • Bug fix

How Has This Been Tested?

  • Verified Directory.Build.props no longer injects PackageReference items into non-SDK projects

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

Additional context

Addresses feedback from #58.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on standardized repo files from repo-template Scope analyzer PackageReferences to SDK-style projects only in Directory.Build.props Mar 9, 2026
@Chris-Wolfgang Chris-Wolfgang marked this pull request as ready for review March 9, 2026 03:12
Copilot AI review requested due to automatic review settings March 9, 2026 03:12
@Chris-Wolfgang Chris-Wolfgang merged commit fdabf9a into repo Mar 9, 2026
@Chris-Wolfgang Chris-Wolfgang deleted the copilot/sub-pr-58 branch March 9, 2026 03:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Scopes globally injected analyzer PackageReference items in Directory.Build.props so they only apply to SDK-style projects, preventing restore issues for legacy packages.config projects under examples/Net4.8.

Changes:

  • Added Condition="'$(UsingMicrosoftNETSdk)' == 'true'" to the AdditionalFiles ItemGroup.
  • Added the same condition to the analyzer PackageReference ItemGroup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants