microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
379 stars 243 forks source link

Add-Member : Cannot add a member with the name "Version" because a member with that name already exists #3385

Closed caracallynxdev closed 6 months ago

caracallynxdev commented 6 months ago

When running New-BcContainer with the -includeTestToolkit switch enabled, the script fails with the error message:

Add-Member : Cannot add a member with the name "Version" because a member with that name already exists. To overwrite
the member anyway, add the Force parameter to your command.
At C:\Users\MichaelScott\OneDrive - Caracal Lynx
Ltd\Documents\WindowsPowerShell\Modules\BcContainerHelper\2.0.14\AppHandling\Sort-AppFilesByDependencies.ps1:49
char:30
+            $_ | Add-Member -NotePropertyName 'Version' -NotePropertyValue ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (@{AppId=63ca2fa...0-172fef340d3f}:PSObject) [Add-Member], InvalidOpe
   rationException
    + FullyQualifiedErrorId : MemberAlreadyExists,Microsoft.PowerShell.Commands.AddMemberCommand

Run the same command without the switch enabled, runs perfectly.

Scripts used to create container and cause the issue

artifacturl = Get-BcArtifactUrl -storageAccount bcinsider -type Sandbox -country gb
New-BcContainer `
        -accept_eula `
        -containerName $containername `
        -artifactUrl $artifacturl `
        -credential $credential `
        -auth $auth `
        -assignPremiumPlan `
        -useSSL `
        -installCertificateOnHost `
        -updateHosts `
        -includeAL `
        -includeTestLibrariesOnly `
        -includeTestToolkit

Full output of scripts

BcContainerHelper is version 2.0.14
BcContainerHelper is running as administrator
Host is Microsoft Windows 11 Enterprise - Unknown/Insider build
Docker Client Version is 25.0.3
Docker Server Version is 25.0.3
WARNING: Ignoring custom format, because both --format and --quiet are set.
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:10.0.20348.2322
Creating Container BC25-0-DEV
Version: 25.0.16618.0-GB
Style: sandbox
Multitenant: Yes
Platform: 24.0.16518.0
Generic Tag: 1.0.2.15
Container OS Version: 10.0.20348.2322 (unknown)
Host OS Version: 10.0.22631.3155 (Unknown/Insider build)
Using hyperv isolation
Using locale en-GB
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\BcContainerHelper\Extensions\BC25-0-DEV\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupNavUsers.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container BC25-0-DEV from image mcr.microsoft.com/businesscentral:10.0.20348.2322
1324598ac3d83341748762b23283628ee9044f85cb7aef1e3f20afea5ee6ca29
Waiting for container BC25-0-DEV to be ready
Using artifactUrl https://bcinsider.azureedge.net/sandbox/25.0.16618.0/gb
Using installer from C:\Run\240
Installing Business Central: multitenant=True, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\sandbox\25.0.16618.0\gb, platformArtifactPath=c:\dl\sandbox\25.0.16618.0\platform, databasePath=c:\dl\sandbox\25.0.16618.0\gb\BusinessCentral-GB.bak, licenseFilePath=c:\dl\sandbox\25.0.16618.0\gb\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\25.0.16618.0\platform\ServiceTier\Program Files
c:\dl\sandbox\25.0.16618.0\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\25.0.16618.0\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\25.0.16618.0\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\25.0.16618.0\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\25.0.16618.0\platform
c:\dl\sandbox\25.0.16618.0\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\25.0.16618.0\gb\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\25.0.16618.0\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\25.0.16618.0\gb\Extensions
Copying Applications
C:\dl\sandbox\25.0.16618.0\platform\Applications
Copying Applications.GB
C:\dl\sandbox\25.0.16618.0\gb\Applications.GB
Copying dependencies
Importing PowerShell Modules
Restoring CRONUS Demo Database
Setting CompatibilityLevel for tenant on localhost\SQLEXPRESS
Exporting Application to CRONUS
Removing Application from tenant
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Starting Business Central Service Tier
Importing license file
Copying Database on localhost\SQLEXPRESS from tenant to default
Taking database tenant offline
Copying database files
Attaching files as new Database default
Putting database tenant back online
Mounting tenant database
Mounting Database for default on server localhost\SQLEXPRESS with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Stopping Business Central Service Tier
Installation took 440 seconds
Installation complete
Initializing...
Setting host.docker.internal to 10.1.0.4 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 10.1.0.4 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.30.192.1 in container hosts file
Starting Container
Hostname is BC25-0-DEV
PublicDnsName is BC25-0-DEV
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 278A514A34C50890D7868A92BD2F6D5E68C77D7E
DNS identity BC25-0-DEV
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
CertificateThumprint 278A514A34C50890D7868A92BD2F6D5E68C77D7E
Registering event sources
Creating DotNetCore Web Server Instance
Using application pool name: BC
Using default container name: NavWebApplicationContainer
Copy files to WWW root C:\inetpub\wwwroot\BC
Create the application pool BC
Create website: NavWebApplicationContainer with SSL
Update configuration: navsettings.json
Done Configuring Web Client
Enabling Financials User Experience
Dismounting Tenant
Mounting Tenant
Mounting Database for default on server localhost\SQLEXPRESS with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Creating http download site
Setting SA Password and enabling SA
Creating admin as SQL User and add to sysadmin
Creating SUPER user
Assign Premium plan for ADMIN
Container IP Address: 172.30.195.212
Container Hostname  : BC25-0-DEV
Container Dns Name  : BC25-0-DEV
Web Client          : https://BC25-0-DEV/BC/?tenant=default
Dev. Server         : https://BC25-0-DEV
Dev. ServerInstance : BC
Dev. Server Tenant  : default
Setting BC25-0-DEV to 172.30.195.212 in host hosts file
Setting BC25-0-DEV-default to 172.30.195.212 in host hosts file
Setting BC25-0-DEV-default to 172.30.195.212 in container hosts file

Files:
http://BC25-0-DEV:8080/ALLanguage.vsix
http://BC25-0-DEV:8080/certificate.cer

Container Total Physical Memory is 8.5Gb
Container Free Physical Memory is 5.1Gb

Initialization took 191 seconds
Ready for connections!
Reading CustomSettings.config from BC25-0-DEV
Certificate with thumbprint 278A514A34C50890D7868A92BD2F6D5E68C77D7E imported successfully
Creating Desktop Shortcuts for BC25-0-DEV
Synchronizing Permissions Mock on default
App successfully synchronized
Installing Permissions Mock on default
App successfully installed
Synchronizing Test Runner on default
App successfully synchronized
Installing Test Runner on default
App successfully installed
Synchronizing Any on default
App successfully synchronized
Installing Any on default
App successfully installed
Synchronizing Library Assert on default
App successfully synchronized
Installing Library Assert on default
App successfully installed
Skipping app 'C:\Applications.GB\Microsoft_Permissions Mock_25.0.16618.0.app' as it is already installed
Synchronizing Library Variable Storage on default
App successfully synchronized
Installing Library Variable Storage on default
App successfully installed
Add-Member : Cannot add a member with the name "Version" because a member with that name already exists. To overwrite
the member anyway, add the Force parameter to your command.
At C:\Users\MichaelScott\OneDrive - Caracal Lynx
Ltd\Documents\WindowsPowerShell\Modules\BcContainerHelper\2.0.14\AppHandling\Sort-AppFilesByDependencies.ps1:49
char:30
+ ...        $_ | Add-Member -NotePropertyName 'Version' -NotePropertyValue ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (@{AppId=63ca2fa...0-172fef340d3f}:PSObject) [Add-Member], InvalidOpe
   rationException
    + FullyQualifiedErrorId : MemberAlreadyExists,Microsoft.PowerShell.Commands.AddMemberCommand
...

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
6.0.6      BcContainerHelper                   PSGallery            PowerShell module, which makes it easier to wor.
caracallynxdev commented 6 months ago

Please ignore this issue; I was running the wrong version of BCContainerHelper. Sorry.

freddydk commented 6 months ago

Please ignore this issue; I was running the wrong version of BCContainerHelper. Sorry.

Thanks for notifying us