Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring settings for a nuget package. Is there a better way?
    text
    copied!<p>I have a <a href="http://nuget.org/List/Packages/Humpback" rel="nofollow">console application that is available via nuget</a> or <a href="https://github.com/jasonmw/Humpback" rel="nofollow">on it's own</a>. It gets installed into the tools directory for the NuGet package. The application requires 3 pieces of 'configuration' information.</p> <ul> <li>a database connection string </li> <li>a folder path </li> <li>one more configuration option (string) </li> </ul> <p>Currently, I store these configuration values in a text file right next to the exe in a file called settings.js, serialized as json. </p> <p>When the application first runs, if the file is not present, it creates one with default values.</p> <p>I keep the settings.js file in this location so the file will get checked into source control.</p> <p>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.</p> <p>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.</p> <pre><code>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 } } </code></pre> <p>Also, init.ps1 doesn't appear to run when installing a package using the command line tool (nuget.exe). Is this expected behavior?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload