Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:59:08+00:00 2026-06-07T17:59:08+00:00

I am creating a NuGet package, and I would like the package to display

  • 0

I am creating a NuGet package, and I would like the package to display a notification whenever an update for the package is present in the repository (which is a private repository, not the official NuGet repository).

Please note that I do not want the package to update itself automatically (in case the new version might introduce some problems), but just notify the user.

To do this, I added this in my init.ps1 file in the package:

param($installPath, $toolsPath, $package, $project)
$PackageName = "MyPackage"
$update = Get-Package -Updates | Where-Object { $_.Id -eq $PackageName }
if ($update -ne $null -and $update.Version -gt $package.Version) {
    [System.Windows.Forms.MessageBox]::Show("New version $($update.Version) available for $($PackageName)") | Out-Null
}

The check on $update.Version -gt $package.Version is needed to avoid showing the notification when the newer package is being installed.

I would like to know if

  1. This solution is acceptable, or if there is a better and “standard” way to do this (rather than brewing my own solution).
  2. There is a better way to show a notification, as the MessageBox is rather annoying: it hides behind the “preparing solution” dialog when I open the project, and the operation does not complete until I click ok.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:59:09+00:00Added an answer on June 7, 2026 at 5:59 pm

    In the end, I’ve found no better way to show a notification than through the init.ps1 file.
    I also discovered that the init script is run only if the Package Manager Console is visible, which is not exactly ideal for this purpose, but still I couldn’t find anything better.

    About the way to notify the user, I’ve found some methods, which I’m posting here in case they might be useful for someone else.

    param($installPath, $toolsPath, $package, $project)
    if ($project -eq $null) {
        $projet = Get-Project
    }
    
    $PackageName = "MyPackage"
    $update = Get-Package -Updates -Source 'MySource' | Where-Object { $_.Id -eq $PackageName }
    # the check on $u.Version -gt $package.Version is needed to avoid showing the notification
    # when the newer package is being installed
    if ($update -ne $null -and $update.Version -gt $package.Version) {
    
        $msg = "An update is available for package $($PackageName): version $($update.Version)"
    
        # method 1: a MessageBox
        [System.Windows.Forms.MessageBox]::Show($msg) | Out-Null
        # method 2: Write-Host
        Write-Host $msg
        # method 3: navigate to a web page with EnvDTE
        $project.DTE.ItemOperations.Navigate("some-url.html", [EnvDTE.vsNavigateOptions]::vsNavigateOptionsNewWindow) | Out-Null
        # method 4: show a message in the Debug/Build window
        $win = $project.DTE.Windows.Item([EnvDTE.Constants]::vsWindowKindOutput)
        $win.Object.OutputWindowPanes.Item("Build").OutputString("Update available"); 
        $win.Object.OutputWindowPanes.Item("Build").OutputString([Environment]::NewLine)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating NuGet package and for that I have created Nuspec manifest file.
Creating a C# install package and I'd like on completed install for the Program
I'm creating a nuget package that I want to be compatible for both MVC2
I'm interested in creating a NuGet package for a documentation tool I'm writing. Ideally,
I am creating a nuget package and I want it to add a post-build
I'm creating my first nuget package. I added a dependency with a version that
I am creating NuGet Package and facing one issue that how can i apply
Creating a simple public/private keypair, such as through ssh-keygen does not create a file
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
Creating an installer for possible remote systems so that if they do not have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.