We have exported our Octopus Deploy server (version 3.1.3) using the Octopus Server Manager, and now we are trying to import it into a fresh Octopus installation (version 3.1.4). While importing we get the following error message:
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Octopus.Migrator.ImportProcess.ImportController.ImportScript(ImportContext context, String scriptFile) in Y:\work\refs\tags\3.1.4\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 444
at Octopus.Migrator.ImportProcess.ImportController.ImportScripts(ImportContext context) in Y:\work\refs\tags\3.1.4\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 410
at Octopus.Migrator.ImportProcess.ImportController.Import(IImportedDocumentSource backup) in Y:\work\refs\tags\3.1.4\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 112
at Octopus.Migrator.Commands.ImportFilesCommand.Start() in Y:\work\refs\tags\3.1.4\source\Octopus.Migrator\Commands\ImportFilesCommand.cs:line 90
at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in Y:\work\refs\tags\3.1.4\source\Octopus.Shared\Startup\AbstractCommand.cs:line 57
at Octopus.Shared.Startup.ConsoleHost.Run(Action`1 start, Action shutdown) in Y:\work\refs\tags\3.1.4\source\Octopus.Shared\Startup\ConsoleHost.cs:line 72
at Octopus.Shared.Startup.OctopusProgram.Run() in Y:\work\refs\tags\3.1.4\source\Octopus.Shared\Startup\OctopusProgram.cs:line 87
It appears to occur while importing the different steps for projects. The preceeding logs looks like this (redacted with some imaginary names):
INFO Examining script file C:\Temp\TestExport\Projects\MyProj\MyProj - Create My Application - Create My Application - Script.ps1
INFO [Project, K:MyProj, N:'MyProj', S:Projects-40, D:-05da0de1259, O:]
INFO deploymentprocess-Projects-40
INFO Create CCAT Application - Script.ps1 skipped because no overwrites selected
INFO Examining script file C:\Temp\TestExport\Projects\MyProj\MyProj - Create My Application - AlternateNet - Create My Application - AlternateNet - Script.ps1
INFO [Project, K:MyProj, N:'MyProj', S:Projects-40, D:-05da0de1259, O:]
INFO deploymentprocess-Projects-40
By doing some testing I have come to the conclusion that it is caused by a dash character (’-’) in step names with the same value up until the dash, e.g.:
Create My Application
Create My Application - AlternateNet
This generates the two scripts:
MyProj - Create My Application - Create My Application - Script.ps1
MyProj - Create My Application - AlternateNet - Create My Application - AlternateNet - Script.ps1
If I change the step name to not use dashes, e.g. to Create My Application with AlternateNet
the import of the step succeeds (although the entire import later failed on another step following the same convention).