PortableApps / Launcher

The PortableApps.com Launcherâ„¢ allows developers, publishers and even technical end-user to portablize apps in PortableApps.com Format without needing to write any code.
https://portableapps.com/apps/development/portableapps.com_launcher
GNU General Public License v2.0
43 stars 13 forks source link

DotNet handling does not support 4.5+ #2

Closed GordCaswell closed 7 years ago

GordCaswell commented 7 years ago

DotNet handling currently supports up to 4.0

4.5+ handling is needed. I am working on a fix.

daemondevin commented 7 years ago

I don't know what it is with you and John (Am I retarded or something?), but I could have sworn I gave you guys a perfectly code function to support checking for 4.5 and above. In case you missed it here it is again:

Function dotNETCheck
    !define CheckDOTNET "!insertmacro _CheckDOTNET"
    !macro _CheckDOTNET _RESULT _VALUE
        Push `${_VALUE}`
        Call dotNETCheck
        Pop ${_RESULT}
    !macroend
    Exch $1
    Push $0
    Push $1

    ${If} $1 == "4.7"
        StrCpy $R1 460798
    ${ElseIf} $1 == "4.6.2"
        StrCpy $R1 394802
    ${ElseIf} $1 == "4.6.1"
        StrCpy $R1 394254
    ${ElseIf} $1 == "4.6"
        StrCpy $R1 393295
    ${ElseIf} $1 == "4.5.2"
        StrCpy $R1 379893
    ${ElseIf} $1 == "4.5.1"
        StrCpy $R1 378675
    ${ElseIf} $1 == "4.5"
        StrCpy $R1 378389
    ${Else}
        Goto dotNET_FALSE
    ${EndIf}

    ReadRegDWORD $R0 HKLM `SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full` `Release`
    IfErrors dotNET_FALSE

    IntCmp $R0 $R1 dotNET_TRUE dotNET_FALSE

    dotNET_TRUE:
    StrCpy $0 true
    Goto dotNET_END

    dotNET_FALSE:
    StrCpy $0 false
    SetErrors

    dotNET_END: 
    Pop $1
    Exch $0
FunctionEnd

Now if you need help using it in your current segment file then you could use it like this:

Function dotNETCheck
    !define CheckDOTNET "!insertmacro _CheckDOTNET"
    !macro _CheckDOTNET _RESULT _VALUE
        Push `${_VALUE}`
        Call dotNETCheck
        Pop ${_RESULT}
    !macroend
    Exch $1
    Push $0
    Push $1

    ${If} $1 == "4.7"
        StrCpy $R1 460798
    ${ElseIf} $1 == "4.6.2"
        StrCpy $R1 394802
    ${ElseIf} $1 == "4.6.1"
        StrCpy $R1 394254
    ${ElseIf} $1 == "4.6"
        StrCpy $R1 393295
    ${ElseIf} $1 == "4.5.2"
        StrCpy $R1 379893
    ${ElseIf} $1 == "4.5.1"
        StrCpy $R1 378675
    ${ElseIf} $1 == "4.5"
        StrCpy $R1 378389
    ${Else}
        Goto dotNET_FALSE
    ${EndIf}

    ReadRegDWORD $R0 HKLM `SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full` `Release`
    IfErrors dotNET_FALSE

    IntCmp $R0 $R1 dotNET_TRUE dotNET_FALSE

    dotNET_TRUE:
    StrCpy $0 true
    Goto dotNET_END

    dotNET_FALSE:
    StrCpy $0 false
    SetErrors

    dotNET_END: 
    Pop $1
    Exch $0
FunctionEnd

${SegmentFile}
${SegmentInit}
    ; If appinfo.ini\[Dependencies]:UsesDotNetVersion is not empty, search
    ; for a .NET Framework install of the specified version. Valid version
    ; numbers are:
    ;
    ;  - (1.0|1.1|2.0|3.0|3.5)[SP<n>]
    ;  - 4.0[SP<n>][C|F]
    ;
    ; Added by demon.devin
    ;  - (4.7|4.6.2|4.6.1|4.6|4.5.2|4.5.1|4.5)
    ; 
    ReadINIStr $0 $EXEDIR\App\AppInfo\appinfo.ini Dependencies UsesDotNetVersion
    ${If} $0 != ""
        ${CheckDOTNET} $1 "$0"
        ${If} ${Errors}
            ${IfThen} $0 == "4.0" ${|} StrCpy $0 "4.0c" ${|}
            ${If} ${HasDotNetFramework} $0
                ; Required .NET version found. Has 4.0 or below.
                ${DebugMsg} "The required .NET Framework was found.$\r$\nVersion found: $0"
            ${ElseIf} ${Errors}
                ; Invalid .NET version
                ${InvalidValueError} [Dependencies]:UsesDotNetVersion $0
            ${Else}
                ; Required .NET version not found
                ${DebugMsg} "Unable to find .NET Framework $0"
                MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoDotNet)`
                Quit
            ${EndIf}
        ${Else}
            ; Required .NET version found. Has 4.5 or above.
            ${DebugMsg} "The required .NET Framework was found."
        ${EndIf}
    ${EndIf}
!macroend

Forgive me if I screwed up and/or forgot something from your original code in the DotNet.nsh. I just wrote all that out from memory as I just fixed the DotNet segment on my version.

daemondevin commented 7 years ago

Here's a better(probably) means for .NET checking in the DotNet segment (this code needs the DotNetVer.nsh header file included too):

Function dotNETCheck
    !define CheckDOTNET "!insertmacro _CheckDOTNET"
    !macro _CheckDOTNET _RESULT _VALUE
        Push `${_VALUE}`
        Call dotNETCheck
        Pop ${_RESULT}
    !macroend
    Exch $1
    Push $0
    Push $1

    ${If} $1 == "4.7"
        StrCpy $R1 460798
    ${ElseIf} $1 == "4.6.2"
        StrCpy $R1 394802
    ${ElseIf} $1 == "4.6.1"
        StrCpy $R1 394254
    ${ElseIf} $1 == "4.6"
        StrCpy $R1 393295
    ${ElseIf} $1 == "4.5.2"
        StrCpy $R1 379893
    ${ElseIf} $1 == "4.5.1"
        StrCpy $R1 378675
    ${ElseIf} $1 == "4.5"
        StrCpy $R1 378389
    ${Else}
        Goto dotNET_FALSE
    ${EndIf}

    ReadRegDWORD $R0 HKLM `SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full` `Release`
    IfErrors dotNET_FALSE

    IntCmp $R0 $R1 dotNET_TRUE dotNET_FALSE

    dotNET_TRUE:
    StrCpy $0 true
    Goto dotNET_END

    dotNET_FALSE:
    StrCpy $0 false
    SetErrors

    dotNET_END: 
    Pop $1
    Exch $0
FunctionEnd

!include DotNetVer.nsh

${SegmentFile}
${SegmentInit}
    ; If appinfo.ini\[Dependencies]:UsesDotNetVersion is not empty, search
    ; for a .NET Framework install of the specified version. Valid version
    ; numbers are:
    ;
    ;  - (1.0|1.1|2.0|3.0|3.5)[SP<n>]
    ;  - 4.0[SP<n>][C|F]
    ;
    ; Added by demon.devin
    ;  - (4.7|4.6.2|4.6.1|4.6|4.5.2|4.5.1|4.5)
    ; 
    ReadINIStr $0 $EXEDIR\App\AppInfo\appinfo.ini Dependencies UsesDotNetVersion
    ${If} $0 <= "4.0"
        !define dotNETVersion "$0"
        ${IfNot} ${HasDotNet4.0}
            ${DebugMsg} "Unable to find .NET Framework ${dotNETVersion}." ; Required .NET version not found
            MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoDotNet)`
            Quit
        ${Else}
            ${DebugMsg} ".NET Framework ${dotNETVersion} found." ; Required .NET version found. 4.0 or below.
        ${EndIf}
    ${ElseIf} $0 >= "4.5"
        ${CheckDOTNET} $R0 $0
        IfErrors 0 +4
        ${DebugMsg} "Unable to find .NET Framework $0" ; Required .NET version not found
        MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoDotNet)`
        Quit
        ${DebugMsg} "The required .NET Framework was found." ; Required .NET version found. Has 4.5 or above.
    ${Else}
        ; Invalid .NET version
        ${InvalidValueError} [Dependencies]:UsesDotNetVersion $0
    ${EndIf}
!macroend

I can add code to support [SP<n>][C|F] for 4.0 below, but my brain is going numb and should take a walk outside for a little bit ..lol.

3D1T0R commented 7 years ago

@demondevin: You don't seem to get that there's already existing code for this which just needs to be expanded to cover the new versions (as well as keeping the old intact and working).

On the other hand, ReVolly/NsisDotNetChecker looks like it could replace our system, include support for old & new versions of .Net and offer to download a version specific .Net Installer for those who can and want to install it.

Update: NsisDotNetChecker has a few issues which it's current maintainer hasn't bothered to fix even though some are trivial to fix, and some have perfectly valid Pull Requests which could simply be merged to fix them.

daemondevin commented 7 years ago

@3D1T0R You obviously didn't review the code I had shared. It still uses the old method. It just provides a means for what @GordCaswell had mentioned which was he needed a means of handling 4.5 and above.

I'm beginning to think my efforts to contribute and share with this brilliant project is becoming a bit trivial. It's little (or no) avail when it comes to being apart of this community. I'm I in a state of paranoia or am I on to something here? Forgive me if I'm wrong but if I'm right, may I at least ask why?! I feel like I've given too much of my time to the PA.c community just to be shot-down and shunned. I hope I'm grasping at straws here.

3D1T0R commented 7 years ago

I did notice that it uses the same style & methodology, but at a quick glance, it looks like it replaces what we have, and doesn't include the old portion.

I haven't dug into the code for DotNet handling in PAL lately (I will), but if your code is in fact an addition to what's already there, and works appropriately, then make a pull request which adds it where you intend it to go so we can have a proper code-review instead of random hunks of code flying at us at every turn, personally that's my issue with your current approach, everywhere I go you're just throwing code at us with no context.

daemondevin commented 7 years ago

Even though I might have joined GitHub a few years ago, I'm very new to using GitHub and a complete novice to the entire idea of the versioning control system. I'm still a bit leery on what pushing/pulling really mean or actually do.

If you want to see the working method that I've shared here then visit my forked project (I do know what that means ..lol.). I guess I must have forked the wrong version of PAL because I didn't fork this repo; I forked the version from @GordCaswell's repo.

3D1T0R commented 7 years ago
  1. Fork this repo
  2. Clone your fork
  3. Create a new branch (name it something that describes what you're doing e.g. improve_dotnet_handling)
  4. Make your changes, and commit them in that branch
  5. Push that branch back to GitHub (on your fork) (unless you messed with your remotes you should be able to just run git push origin)
  6. In your browser, go to your repository, switch to that branch, and click "Pull Request"
  7. Make sure the 'base fork', 'base', 'head fork' and 'head' show the right repositories & branches
  8. Write a good description & information about what your Pull Request is supposed to do
  9. Click "Create pull request" at the bottom
daemondevin commented 7 years ago

That seems like a lot to swallow, but I'll give it a shot tomorrow and see what I come up with.

Honestly, I don't think this repo is ready for what I've done with my fork.. Lol.

Baby steps of course. =)

3D1T0R commented 7 years ago

So @GordCaswell, is this fixed by f317e48d805baef8ef0a71b87d49fe4485d8beb2, b48fa1e45f9acead74bcd4af4ee83c67811885b6 & 3ce4fd91b5943751acbe31db980aaa7cb8610dbe? or are there still problems with it?

GordCaswell commented 7 years ago

@3D1T0R, now that I've pushed it to the repo, this issue is fixed fully in [3ce4fd9], so I'm closing the issue.(https://github.com/PortableApps/Launcher/commit/3ce4fd91b5943751acbe31db980aaa7cb8610dbe)