d365collaborative / d365fo.tools

Tools used for Dynamics 365 Finance and Operations
MIT License
246 stars 101 forks source link

Error when calling Invoke-D365SDPInstall with relative path #622

Closed FH-Inway closed 2 years ago

FH-Inway commented 2 years ago

I tried to install a software deployable package (MS update 10.0.24) on a local vhd with the Invoke-D365SDPInstall cmdlet.

The cmdlet was called from the path were the package .zip file was located. I used tab completion for the path parameter, which looked like this: C:\Temp> Invoke-D365SDPInstall -Path .\FinanceAndOperations_10.0.1084.80_10.0.24_PU48.zip -Command RunAll -RunbookId "10.0. 24-20220125-01" -ShowOriginalProgress

The unpacking of the .zip file was successful, but after that I got an error that contained the following message: Could not find a part of the path 'C:\windows\system32\FinanceAndOperations_10.0.1084.80_10.0.24_PU48\Microsoft.Dynamics.AX.AXInstallationInfo.dll_shadow.dll'.

I then tried to call the cmdlet with the relative path of the unzipped folder, which gave the same error. Only when I switched to the absolute path, it worked:

Invoke-D365SDPInstall -Path C:\Temp\FinanceAndOperations_10.0.1084.80_10.0.24_PU48\ -Command RunAll -RunbookId "10.0.24-20220125-01" -ShowOriginalProgress

Gist with full error d365fo.tools version: 0.6.70

Splaxi commented 2 years ago

What if you did a full path to the zip file?

Looking at the code, I can see we don't take all possible scenarios into consideration in regards to relative paths.

For now we expect a full path zip OR a relative path to an extracted folder.

FH-Inway commented 2 years ago

I also got the error when using the relative path of the extracted folder. Using the absolute path for the .zip file works.

Splaxi commented 2 years ago

What if you are cd into the folder (extracted) directly?

What would you like us to support, so we can brainstorm what we should support.

FH-Inway commented 2 years ago

What if you are cd into the folder (extracted) directly?

Will try that next chance I get.

What would you like us to support, so we can brainstorm what we should support.

We should check the path and if it is relative, either give the user a warning that relative paths are not supported or transform it into an absolute path that the cmdlet can work with.

FH-Inway commented 2 years ago

What if you are cd into the folder (extracted) directly?

That works. If I call C:\Temp\Update> Invoke-D365SDPInstall -Path . -Command RunAll -RunbookId "10.0.25-20220203-01" -ShowOriginalProgress where C:\Temp\Update is the extracted folder, the update runs as expected.

Splaxi commented 2 years ago

Any ideas on how we can approach this?

Would you say that the current solution works, if we start providing a detailed message saying that the user should be inside the directory of the extracted folder or pass the complete path? Or do you feel that we should support your initial attemp?

FH-Inway commented 2 years ago

I noticed that pr #283 by @oathgg already introduced some handling of relative paths, which is why the call from inside the extracted folder works. I expanded on that, the cmdlet should now be able to handle additional relative path scenarios. I tested a few and also did some regression testing with absolute paths.

FH-Inway commented 2 years ago

Fixed in version 0.6.73