majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

The global variable `$au_version` is not propagated to $Latest.Version #268

Closed moh-hassan closed 2 years ago

moh-hassan commented 2 years ago

I run the code:

  $au_Version='1.2.3' ; ./update.ps1

Then I get the exception:

Invalid version:
At C:\Program Files\WindowsPowerShell\Modules\au\2021.7.18\Public\Update-Package.ps1:210 char:46
+ … ion $Latest.Version)) { throw "Invalid version: $($Latest.Version)" }
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (Invalid version: :String) [], RuntimeException
+ FullyQualifiedErrorId : Invalid version:

I expect that $Latest.Version is updated to $au_Version To resolve this issue, I had to:

function global:au_GetLatest { 
    return @{
        Version    = $au_Version  
        #...
    }     
}

Can $au_Version update $Latest.Version automatically?

majkinetor commented 2 years ago

au_Version is used only when package is forced as to avoid automatic "fix" version. You specify version directly in au_GetLatest the way you did manually, but you can also use mechanism you provided.

moh-hassan commented 2 years ago

It's nice if $au_version can update $Latest.Version (when it's null ) , especially it's the core variable for updating the version in nuspec file.

majkinetor commented 2 years ago

Its not core vairable and mechanism you provided works. This is generally not the usuall workflow people do - they do not specify manually version over the command line but use Internet to get it.

moh-hassan commented 2 years ago

In my scenario, I have chocolatey package in my project (not a separate project, so no need for remote url to extract the version), and I embed the binaries from disk in the package after building the project then pack and push from within appveyor. It's more commonly used in many projects.

majkinetor commented 2 years ago

Why do you need AU then ? You can replace lines in your own package in number of ways.

moh-hassan commented 2 years ago

Sure I need AU to auto update my package. It simplify the update tasks :).

majkinetor commented 2 years ago

Hah, ok, if so, just use the method you described, no big deal.