jeremytammik / RevitLookup

Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
http://thebuildingcoder.typepad.com
MIT License
1.03k stars 294 forks source link

Couldn´t find the msi installer for latest version #116

Closed arqn closed 2 years ago

arqn commented 2 years ago

Hi; I couldn´t find the latest version .msi installer, instead, I have found the version installer for revit 2021.

Am I doing something wrong or maybe from version 2022 the installation process changes?

Thanks for all

Nice3point commented 2 years ago

Hi, did you download this file according to the instructions in the Readme? изображение

The installer contains the latest version 2022, check this path %APPDATA%\Autodesk\Revit\Addins\2022, does it contain these files? изображение

ricaun commented 2 years ago

I was messing with deploying a release using GitHub workflow runs, which works great.

But in this project, I didn't find a good way to get the file version or release version, the MSI file does not have a ProductVersion and FileVersion.

I don't know if is possible to add this version to the MSI installation file.

Nice3point commented 2 years ago

@ricaun ProductVersion and FileVersion are dll properties, not MSI, which versions do you mean? The installer has its own product version and it is displayed in the Windows control panel. изображение

and the plugin dll has the same version изображение

ricaun commented 2 years ago

I never use MSI so I did not know MSI does not have ProductVersion and FileVersion.

I want to use some PowerShell to get the version on the workflow and apply it to the Release tag and name.

I found this: https://technotes.khitrenovich.com/check-msi-version-powershell/

Looks promising...

Nice3point commented 2 years ago

aren't you considering creating a release through Nuke? you can set the task of creating a release after creating the installer. You can get the version number from the Project properties, I can help with code, tomorrow. I will create a test repository, or we can work in your fork, give me access to the project, I'll set up a Nuke plan https://www.ariank.dev/create-a-github-release-with-nuke-build-automation-tool/

ricaun commented 2 years ago

Interesting, I didn't know it is possible using Nuke. By de look you need to mess with GithubRepositoryAuthToken, I don't want that... I already have a workflow that send the artifact files to the release. Only need to to find a better way to check the compiled version.

Nice3point commented 2 years ago

I'll think about it, maybe there's an option to do it with Nuke. And remove the publication of artifacts. If it doesn't work out, there are a couple of ideas to do using Yml

Nice3point commented 2 years ago

@ricaun it is possible to pass $ {{secrets.GITHUB_TOKEN}} as a parameter for Nuke, but I did not find where to use it, apparently authorization is needed. Within YML, you can use Regex in the output directory, the file name contains the version number, also the MSI file has a Version property, you can use it

ricaun commented 2 years ago

@ricaun it is possible to pass $ {{secrets.GITHUB_TOKEN}} as a parameter for Nuke, but I did not find where to use it, apparently authorization is needed. Within YML, you can use Regex in the output directory, the file name contains the version number, also the MSI file has a Version property, you can use it

Probably is possible to use the environment variable, is possible to set on the YML and then consume inside the nuke, need to test but I believe should work.

My release test works! :)

image

I set some environment variables to set the repository name and version release.

Nice3point commented 2 years ago

Nice! try to get the version number from the name of the MSI file and set the env var, it is generated in the output folder, which is in the root of the solution. изображение

ricaun commented 2 years ago

Nice! try to get the version number from the name of the MSI file and set the env var, it is generated in the output folder, which is in the root of the solution. изображение

I gonna use this ps1 script:

###############################################################
# Name:         GetMsiVersion.ps1
# Description:  Prints the largest version of the MSI files installer
# Usage:        .\GetMsiVersion.ps1 .\*.msi
# Original:     http://stackoverflow.com/q/8743122/383673
###############################################################

param (
    [string]$path
)

try {
    $version = [System.Version]::Parse("0.0.0.0")
    Get-ChildItem –Path $path | 
    Foreach-Object {
        $MSI = $_
        $windowsInstaller = New-Object -com WindowsInstaller.Installer
        $database = $windowsInstaller.GetType().InvokeMember(
            "OpenDatabase", "InvokeMethod", $Null,
            $windowsInstaller, @($MSI.FullName, 0)
        )

        $q = "SELECT Value FROM Property WHERE Property = 'ProductVersion'"
        $View = $database.GetType().InvokeMember(
            "OpenView", "InvokeMethod", $Null, $database, ($q)
        )

        $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null)
        $record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null )
        $productVersion = $record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $record, 1 )

        $versionFile = [System.Version]::Parse($productVersion) 
        if ($versionFile -gt $version) 
        {
            $version = $versionFile    
        }
    }
    return $version.toString()
} catch {
    throw "Failed to get MSI file version: {0}." -f $_
}

Some code like this $version = .\Build\GetMsiVersion.ps1 .\output\*.msi

Nice3point commented 2 years ago

$q = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" this line won't work try use this https://stackoverflow.com/questions/48409026/powershell-extract-number-from-file-name Regex (\d+.)+\d+ изображение

Nice3point commented 2 years ago

@ricaun

param ([string]$path)

Get-ChildItem $path | Where {$_.extension -eq ".msi"} | Where {$_.Name -match '(\d+.)+\d+'} | ForEach {return $Matches[0]}

изображение

Nice3point commented 2 years ago

add an exception if possible if the result of the script is string.Empty to cancel the creation of the release. and as requested by Jeremy, add this version number 20 at the beginning to keep the current versioning) or wait, I will add 20 prefix to the installer file. the update will be in the dev branch

https://github.com/jeremytammik/RevitLookup/commit/ff9c12e2b8949d4e55525e5451251cfde570ffb9

ricaun commented 2 years ago

$q = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" this line won't work try use this https://stackoverflow.com/questions/48409026/powershell-extract-number-from-file-name Regex (\d+.)+\d+ изображение

Strange the GetMsiVersion.ps1 is working fine on workflow runs.

I don't like the idea to read the file name to get the version, if the file name change for some reason could cause some issue.

Nice3point commented 2 years ago

less code, less errors, faster script execution) The version in the file name and the installer property are taken from one variable. I don't think the style of the filename will change anytime soon. but if you want you can leave your version. just change the script so that it doesn't return "0.0.0.0" if there are no msi files. Declare "0.0.0.0" as a constant, and when exiting the script, compare it with the version number, if they are the same, throw an exception. The outer try catch block can be removed

Nice3point commented 2 years ago

@ricaun I did it 🤯🥳 I created a Release via Nuke, for authorization it is sufficient to pass $ {{secrets.GITHUB_TOKEN}} as an argument.

изображение

Writing in C # is much better than in YML. It remains to automate the receipt of the version number and add a Changelog, I am thinking of getting it from the Changelog.md file.

ricaun commented 2 years ago

Nice! Yes c# is much easy to work with.

How are you passing the ${{secrets.GITHUB_TOKEN}}, I was testing using Environment Variables and works.

YML

      - name: Run './Build/build.cmd '
        run: ./Build/build.cmd 
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

C#

Environment.GetEnvironmentVariable("GITHUB_TOKEN")

The version number is equal to the version number and the tag is equal to the DLL version, which is how Jeremy is using.

Using the Changelog.md file is a great idea, I don't know if you are adding Release with the CreatePackage.yml or a separated workflow_dispatch. If a Release already exists with the same tag could cause some error, but in C# probably is easy to delete, rename and do everything you want.

Nice3point commented 2 years ago

изображение изображение

All tags can be obtained from this place (screenshot below), find the largest version, check that the new version is older than the one found and does not coincide with the existing ones. In the case when attempts to create a release with an existing tag, the release will be created, but the Draft properties will remain true: изображение In c #, the msi version number is pretty easy to get. I will finalize the code one of these days

ricaun commented 2 years ago

Woooo Nuke is really powerful, I was looking to check how to sign files using Nuke.

I don't know exactly what [Secret] does in front of the [Parameter] but by looking at common attribute in token/password parameter.

Nice3point commented 2 years ago

There are many examples in the Nuke repository, for example this one, apparently they sign their package here https://github.com/nuke-build/nuke/blob/develop/source/Nuke.Components/ISignPackages.cs

Nice3point commented 2 years ago

Hmm, maybe the Secret attribute encrypts the debugging parameter, i don't know why it is needed, gitAction does it itself, and replaces everything with asterisks

Nice3point commented 2 years ago

@arqn https://github.com/jeremytammik/RevitLookup#installation