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 5964179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:23:06+00:00 2026-05-22T19:23:06+00:00

I have a console application that is available via nuget or on it’s own

  • 0

I have a console application that is available via nuget or on it’s own. It gets installed into the tools directory for the NuGet package. The application requires 3 pieces of ‘configuration’ information.

  • a database connection string
  • a folder path
  • one more configuration option (string)

Currently, I store these configuration values in a text file right next to the exe in a file called settings.js, serialized as json.

When the application first runs, if the file is not present, it creates one with default values.

I keep the settings.js file in this location so the file will get checked into source control.

My question is about maintaining the settings file across versions.
If you Update-Package via nuget, everything works great, except the new version doesn’t have any settings i had configured, because there is a new folder created for the new version.

I have written a powershell script to run in init.ps1 to pull the settings from the last version of the package, and seems to work. However this feels kinda dirty and I am wondering if there is a better way to solve this problem when using nuget to deliver my application.

param($installPath, $toolsPath, $package)
Set-Alias hump (Join-Path $toolsPath hump.exe)

$sorted_list = new-object system.collections.SortedList
$parent_path = Join-Path $installPath ".."
foreach($f in Get-ChildItem $parent_path -Filter Humpback* | Foreach {$_.FullName}){
    $sorted_list.Add($f,$f)
}
if($sorted_list.Count -gt 1){
    $old_path = $sorted_list.Values[$sorted_list.Count - 2]
    $new_path = Join-Path $installPath "tools"
    $current_settings = Join-Path $new_path "settings.js"
    $has_current_settings = Test-Path $current_settings
    if($has_current_settings -eq $false){
        $old_settings = Join-Path $old_path "tools\settings.js"
        Copy-Item $old_settings  $new_path
    }
}

Also, init.ps1 doesn’t appear to run when installing a package using the command line tool (nuget.exe). Is this expected behavior?

  • 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-05-22T19:23:07+00:00Added an answer on May 22, 2026 at 7:23 pm

    Can you access System.Environment.GetFolderPath? I’d just create a folder under ApplicationData special folder, and store the settings there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a console application that uses a database connection string which is defined
I have a console application that will be kicked off with a scheduler. If
I have a console application that require to use some code that need administrator
I have a console application that I would like to run as 'NT AUTHORITY\NetworkService',
I have a console application that should do best effort logging to a database
I have a console application that communicates with a web service. Both of them
I have a console application that is trying to load a CustomConfigurationSection from a
I have a console application that sends a XML to a MVC application and
Scenario: I have a console application that needs to access a network share with
I have created a console application that calls a method on a webservice. I

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.