Upgrade to 4.2 fails with System.ArgumentException

Product: PowerShell Universal
Version: 4.2.21

Hello,
I was recently attempting to update PowerShell Universal from 2.10.2 to 4.2.21 and have an issue where PowerShell Universal will not start due to an exception being uncaught.

Application: Universal.Server.exe
CoreCLR Version: 7.0.222.60605
.NET Version: 7.0.2
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.IO.FileInfo..ctor(String originalPath, String fullPath, String fileName, Boolean isNormalized)
   at System.IO.FileInfo..ctor(String fileName)
   at UniversalAutomation.LiteDBv5Database.SetupTables() in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\LiteDBDatabase.cs:line 118
   at UniversalAutomation.LiteDBv5Database..ctor(IServiceProvider serviceProvider, String connectionString) in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\LiteDBDatabase.cs:line 87
   at UniversalAutomation.LiteDBv5.DatabaseFeature.GetDatabase(IServiceProvider serviceProvider, String connectionString) in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\Plugin.cs:line 41
   at Universal.Server.Services.SystemPluginService.<>c__DisplayClass4_0.<AddDatabase>b__2(IServiceProvider x) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\SystemPluginService.cs:line 83
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Universal.Server.Program.<>c__DisplayClass3_0.<Main>b__0(Options o) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Program.cs:line 80
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at Universal.Server.Program.Main(String[] args) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Program.cs:line 52

The MSI installer did create a new appsettings.json in %ProgramData%\PowerShellUniversal with the following Data settings:

  },
  "Plugins": [
    "UniversalAutomation.LiteDBv5"
  ],
  "Data": {
    "RepositoryPath": "%ProgramData%\\UniversalAutomation\\Repository",
    "ConnectionString": "Data Source=%ProgramData%\\UniversalAutomation\\database.db"
  }

The existing appsettings.json in %ProgramData%\PowerShellUniversal\Server has the following connection string:

"ConnectionString": "filename=%ProgramData%\\UniversalAutomation\\database.db;upgrade=true",

I have tried various iterations of the ConnectionString: without upgrade=true, with Data Source= vs filename= and all result in a similar exception when trying to start the service.

We are not running PSU with IIS and relying on Kestrel for the web/admin UI.

Any help would be greatly appreciated.

Thanks,
Cameron Cox

Another user a while back was trying to make a drastic version jump like you are, and ran into similar issues. The solution I provided to them, which worked (as is it does with loads of other softwares/firmwares), was to step the upgrades - don’t just go from A to Z directly. TL;DR: try going to a version in between first, such as 3.x.

For best practice you need to do the following since PSU v4 is completely different than PSU v2.
1- Backup your universalAutomation folder under programdata.
2- uninstall / remove all previeus versions of PSU including modules.
3- install latest versions of powershell & ASP.NET Core Runtime 8.0.4 hosting bundle.
4-Install PSU latest V4 version as fresh install.
5-login and verify all features functionalty.
6-re configure PSU based on your needs e.g dashboards , automation , etc…
7-re work your scripts to work with V4. e.g cmdlets , components, etc…

you need to do the above because there was a lot of changes and updates to v4 compare to v2 and you cannot just upgrade. so many cmdlets has been modified and you need to re visit your scripts to update your code based on these changes.

1 Like

Exactly. Sometimes it’s possible to avoid completely uninstalling old versions by just doing the upgrades in steps rather than jumps but, other times, it’s necessary.

Did you resolve the issues with a stepped upgrade?