Skip to content

Fix PMC commands failing on build warnings in VS 2026#37673

Merged
AndriySvyryd merged 7 commits intomainfrom
copilot/fix-ef-command-error-handling
Feb 12, 2026
Merged

Fix PMC commands failing on build warnings in VS 2026#37673
AndriySvyryd merged 7 commits intomainfrom
copilot/fix-ef-command-error-handling

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

VS 2026 Package Manager Console now fails EF commands (add-migration, remove-migration, update-database) when the build encounters warnings like nuget package vulnerabilities. The module-level $ErrorActionPreference = 'Stop' causes PowerShell to halt on build warnings.

Changes

Wrapped the dotnet build CLI invocation with a try/finally block that:

  • Preserves current $ErrorActionPreference
  • Only sets to 'Continue' during build when originally set to 'Stop' to allow warnings
  • Restores original value after build

Build failures are still caught via error handling in the dotnet build invocation.

Build operation protected:

dotnet build - CLI invocation for ResolvePackageAssets (line 1409)

$previousErrorActionPreference = $ErrorActionPreference
try
{
    if ($ErrorActionPreference -eq 'Stop')
    {
        $ErrorActionPreference = 'Continue'
    }
    $references = (dotnet build ...) -join "`n" | ConvertFrom-Json
}
finally
{
    $ErrorActionPreference = $previousErrorActionPreference
}

Users no longer need -ErrorAction Ignore workaround for PMC commands that trigger the dotnet build CLI call.

Original prompt

This section details on the original issue you should resolve

<issue_title>VS 2026: Package Manage Console now requires "-ErrorAction Ignore" parameter on all EF commands</issue_title>
<issue_description>This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] [regression] [worked-in:17 (vs 2022)]
Since upgrading to VS 2026, If i try to run any EF-related commands, the command will fail. Commands include:

add-migration
remove-migration
update-database

With the error:
"The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop"

These are failing, and have to be appended with ErrorAction Ignore, like:

add-migration "mymigration" -ErrorAction Ignore

The error still displays in the console, but the action continues successfully. The error is technically valid; in my case it is complaining because of nuget 'package vulnerability'. But this shouldn't stop all package manager console commands.

I do have the workaround, but I would appreciate a fix. Thanks!


Original Comments

Feedback Bot on 1/27/2026, 05:17 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 2/11/2026, 09:15 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.

<agent_instructions>Fix this regression in EntityFrameworkCore.psm1 by wrapping dotnet build invocation in try/finally with temporary $ErrorActionPreference = 'Continue'</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix EF command error handling in Package Manager Console Fix PMC commands failing on build warnings in VS 2026 Feb 11, 2026
Copilot AI requested a review from AndriySvyryd February 11, 2026 18:14
Copilot AI requested a review from AndriySvyryd February 11, 2026 21:17
@AndriySvyryd AndriySvyryd marked this pull request as ready for review February 11, 2026 21:37
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner February 11, 2026 21:37
Copilot AI review requested due to automatic review settings February 11, 2026 21:37
Copy link

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

This PR addresses a Visual Studio 2026 regression where EF Core Package Manager Console commands fail when the build emits warnings (e.g., NuGet vulnerability warnings) due to the module’s $ErrorActionPreference = 'Stop'.

Changes:

  • Wraps the dotnet build ... /t:ResolvePackageAssets invocation in a try/finally to temporarily set $ErrorActionPreference to 'Continue' only when it was originally 'Stop'.
  • Restores the previous $ErrorActionPreference after the build-related call completes.

@AndriySvyryd AndriySvyryd enabled auto-merge (squash) February 11, 2026 22:11
@AndriySvyryd AndriySvyryd merged commit 37edffa into main Feb 12, 2026
10 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/fix-ef-command-error-handling branch February 12, 2026 00:22
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.

VS 2026: Package Manage Console now requires "-ErrorAction Ignore" parameter on all EF commands

3 participants

Comments