Cloning pyRevit and our extensions for deployment with Powershell doesn't work

I have created a powershell script following the instructions on Notion – The all-in-one workspace for your notes, tasks, wikis, and databases. to make a deployment for all members of our office.

  • .NET 4.8 gets successfully installed
  • pyRevit CLI gets successfully installed

The environment path was set:

but it seems somehow is does not accept the pyrevit argument.

I have opened Powershell with local admin rights
Set-ExecutionPolicy “RemoteSigned” -force
cd D:\DevProjekte\pyRSE\pyRSEplus.extension\updater
.\cloning_pyrevit.ps1

result screenshot:

/e: if I run this command in the powershell Terminal in visual studio code…

pyrevit extend ui $rseextname $rsepyrevitext --dest=$pyrevitexts --branch=$rsebranch --log=“D:\pyRevitCLI_InstallLog.txt” --debug

…I got the error:

Error: the given reference name 'refs/remotes/origin/' is not valid (pyRevitLabs.Common.PyRevitException)
   bei pyRevitLabs.Common.GitInstaller.Clone(String repoPath, String branchName, String destPath, GitInstallerCredentials creds, Boolean checkout)
   bei pyRevitLabs.PyRevit.PyRevitExtensions.InstallExtension(String extensionName, PyRevitExtensionTypes extensionType, String repoPath, String destPath, String branchName, GitInstallerCredentials credentials)
   bei pyRevitLabs.PyRevit.PyRevitExtensions.InstallExtension(PyRevitExtensionDefinition extDef, String destPath, String branchName)
   bei pyRevitCLI.PyRevitCLI.ProcessArguments()
   bei pyRevitCLI.PyRevit

If I use instead of the argument pyrevit the full path:
& “C:\Program Files\pyRevit CLI\bin\pyrevit.exe”

I get the error message:

Debug: Arg processing failed. | Usage:
        pyrevit (-h | --help)
        pyrevit (-V | --version)
        pyrevit --usage
.......
....etc

If I use in the powershell terminal:
& “C:\Program Files\pyRevit CLI\bin\pyrevit.exe” clone rsemaintest2 base --dest=D:\pyRevit\rsemaintest2\ --log=“D:\pyRevitCLI_InstallLog.txt” --debug

it gets cloned successfully.

Thank you!

/e: solved…
I have moved my own extension into a function and added to the add extension function.
And I have changed

$env:Path = “C:\Program Files\pyRevit CLI”

to

$env:Path = “;C:\Program Files\pyRevit CLI\bin”

and added many other minor fixes and comments, if you like to have a look:
https://github.com/Thomas84/pyRSE/blob/main/updater/cloning_pyrevit.ps1

Hi Thomas,
Wasn’t it just an issue due to the branch being named main instead of master?

Hi Jean-Marc,
maybe, I have added the --branch flag now everywhere with the correct branch name. The file is still work in progress. Would be nice if others can share their powershell config file as well, so I can see additional tricks :slight_smile:

Hi Thomas,
Yep, that probably fixed it.
I did not go through all the comments of your ps file. I am so rusted in German, and feel I need to avoid using google translate to let my brain do the work :slight_smile:

I haven’t gone the PS way. My team being relatively small (30ish) and geeky, I make them install pyRevit and run a command line to install extra extensions.

I will add english comments at a later point in time, sry my bad. Ye, I have read your workflow in another comment. But I want to automate as much as I can, and I think if I have powershell scripts for all typical tasks, it is pretty easy to manage :smiley: I’m just not that powershell geek, but I have already powershell cookbooks on my drive :smiley:

1 Like

The seed command doesn’t work :frowning: Somehow the pyRevit_config.ini gets cloned from and to the same path?! It says it is already in use by another process.

others have mentioned that as well:
# pyRevit on more machines - #3 by giused8
# https://github.com/eirannejad/pyRevit/issues/1243#issuecomment-1022495668
# Configs Seed Error - #3 by lexiko

The section from the error log:

2022-08-09 13:49:22.9990|DEBUG|pyRevitCLI.PyRevitCLI|Checking for all: seed
2022-08-09 13:49:22.9990|DEBUG|pyRevitLabs.PyRevit.PyRevitConfigs|Seeding config file "C:\ProgramData\pyRevit\pyRevit_config.ini" to "C:\ProgramData\pyRevit\pyRevit_config.ini"
2022-08-09 13:49:23.0159|ERROR|pyRevitCLI.PyRevitCLI|Failed seeding config file. | Der Prozess kann nicht auf die Datei "C:\ProgramData\pyRevit\pyRevit_config.ini" zugreifen, da sie von einem anderen Prozess verwendet wird. (pyRevitLabs.Common.PyRevitException)
   bei pyRevitLabs.PyRevit.PyRevitConfigs.SeedConfig(Boolean lockSeedConfig)
   bei pyRevitCLI.PyRevitCLI.ProcessArguments()

And some configuration settings seem not working:

    Write-Output "pyRevit Konfiguration 1"
    & "C:\Program Files\pyRevit CLI\bin\pyrevit.exe" configs allowremotedll disable --log=$logfile

    Write-Output "pyRevit Konfiguration 13"
    & "C:\Program Files\pyRevit CLI\bin\pyrevit.exe" configs usagelogging disable --log=$logfile

    Write-Output "pyRevit Konfiguration 22"
    & "C:\Program Files\pyRevit CLI\bin\pyrevit.exe" configs usercanupdate Yes --log=$logfile

    Write-Output "pyRevit Konfiguration 23"
    & "C:\Program Files\pyRevit CLI\bin\pyrevit.exe" configs usercanextend Yes --log=$logfile

    Write-Output "pyRevit Konfiguration 24"
    & "C:\Program Files\pyRevit CLI\bin\pyrevit.exe" configs usercanconfig Yes --log=$logfile

I have added the write-output numbers, to see which configs commands doesn’t work.
If I run the Powershell script, on the mentioned commands it seems pyrevit doesn’t know the commands or the flags:

Example screenshot:

/edit:
Yes and No has to be lower case letters, then configs 22, 23, and 24 works… :rofl:
and I assume useagelogging was replaced with the telemetry server stuff
and I assume allowremotedll does only exists in the help and not in the code base.

1 Like

@eirannejad nice set of flags :point_up_2: :slight_smile:

I think the seed error starts here:

edit2:

… and the ConfigFilePath and AdminConfigFilePath will be the same…

…if IsRunAsElevated() gets true (if you run the ps script as admin):

The constants are defined here:

But I think it makes no sense that it copy from and to the same place!? I think there should be a temporary place, where the pyRevitConfig.ini gets prepared and finally it should copied to the programdata or appdata path.

Does it make a difference if I run the powershell as local or global admin?

/edit1:
I will try to use now the command “config” to configure pyRevit on my machine from an existing template configuration file:
pyrevit config <template_config_path> [–log=<log_file>]
$ pyrevit config “C:\myPyRevitTemplateConfig.ini”

Source:

Or maybe with another Powershell script snippet, I think it is the same result.

/edit3:
After inspecting the code, the documentation of pyrevit config is missing the --from= flag
The command only works if you use

pyrevit config --from=“X:<template_config_path>\pyReivt_config.ini”

and then it will be copied to the users %APPDATA%\pyRevit\pyRevit_config.ini.
Not sure yet if this solves my task or if I need to run a powershell script to copy the config template to each user.

2 Likes