Installing MS .NET Framework 4.7.2 SDK fails, but installs

237 views
Skip to first unread message

Edvinas Perminas

unread,
Dec 9, 2020, 8:23:27 AM12/9/20
to Salt-users
Hello all,

I'm trying to install MS .NET Framework 4.7.2 SDK on my Windows 10 Enterprise minion.

Here is the .sls for installing it:
============================================================
{% set installerPath = 'salt://software/NET_Framework_4.7.2_SDK/NDP472-DevPack-ENU.exe' %}

dnet472:
  '4.7.03081':
    full_name: 'Microsoft .NET Framework 4.7.2'
installer: '{{installerPath}}'
install_flags: '/q /norestart'
uninstaller: '{{installerPath}}'
uninstall_flags: '/uninstall /x86 /x64 /q /norestart'
msiexec: False
locale: en_US
reboot: False
============================================================ 

When running it via state.apply:
============================================================
dnet472:
  pkg.installed:
    - name: 'dnet472'
    - version: '4.7.03081'
============================================================ 

The result I get is: .NET is installed, but salt state is set as failed:

=======================
Question: since this is actually installed and shown in Programs on Windows, what causing this failure state? If my next states would be dependent on successful state result for this state, I would not be able to progress further.

I assume this is something due to fact that this .NET exe actually installs Developer Pack and SDK?

I appreciate your time on this!!
Ed 

Edvinas Perminas

unread,
Dec 9, 2020, 8:27:05 AM12/9/20
to Salt-users
Since image is not displaying it says:
ID: dnet472
Function: pkg.installed
Result: False
Comment: The following packages failed to install/update: dnet472=4.7.03081
Started: 05:11:17.218702
Duration: 6984.316 ms
Changes:
------
Microsoft .NET Framework 4.7.2 Developer Pack:
 ---
new:
 4.7.3081
Old:
Microsoft .NET Framework 4.7.2 SDK:
------
new: 4.7.03081
old: 
dnet472:
---------
install status:
 success

Dirk Heinrichs

unread,
Dec 9, 2020, 10:48:33 AM12/9/20
to salt-...@googlegroups.com
Am 09.12.20 um 14:27 schrieb Edvinas Perminas:

Question: since this is actually installed and shown in Programs on Windows, what causing this failure state? If my next states would be dependent on successful state result for this state, I would not be able to progress further.

I assume this is something due to fact that this .NET exe actually installs Developer Pack and SDK?

I appreciate your time on this!!

This is something we see for several packages on Windows. Our workaround is to use module.run instead. Here is our SLS for installing .Net:
dotnet:
{%- if grains['kernel'] == 'Windows' %}
  {%- set dotnet = salt['pillar.get']('microsoft:dotnet') %}
  {%- set filename = dotnet.pkg ~ '-x86-x64-AllOS-ENU.exe' %}
  {%- set source = salt['pillar.get']('SOURCE_LOCATION_THIRD_PARTY') ~ '/dotNet/' ~ filename ~ salt['pillar.get']('SOURCE_ENV', '') %}
  {%- set target = salt['pillar.get']('DEPLOYMENT_PATH') ~ '/store/' ~ filename %}

  {%- if salt['grains.get']('dotnetversion') < dotnet.inst_ver %}
  file.managed:
    - name: {{ target }}
    - makedirs: True
    - source: {{ source }}
    - source_hash: 'sha256={{ dotnet.sha256 }}'
    - retry:
        attempts: 10
        interval: 10
        splay: 5
  module.run:
    - pkg.install:
      - name: dotnet
      - version: {{ dotnet.inst_ver }}
      - saltenv: {{ saltenv }}
      - refresh: True
    - require:
      - file: dotnet
  {%- else %}
  test.succeed_without_changes
  {%- endif %}
{%- else %}
  test.succeed_without_changes
{%- endif %}

Windows package description file:
dotnet:
  {% for version, inst_ver, pkg in [
    ('4.5.2', '4.5.51209', 'NDP452-KB2901907'),
    ('4.6.2', '4.6.01590', 'NDP462-KB3151800'),
    ('4.7', '4.7.02053', 'NDP47-KB3186497'),
    ('4.7.2', '4.7.03062', 'NDP472-KB4054530'),
  ] %}
  {% set installer = salt['pillar.get']('DEPLOYMENT_PATH') ~ '/store/' ~ pkg ~ '-x86-x64-AllOS-ENU.exe' %}
  '{{ inst_ver }}':
    full_name: 'Microsoft .NET Framework {{ version }}'
    installer: {{ installer }}
    install_flags: '/q /norestart'
    uninstaller: 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\SetupCache\v{{ inst_ver }}\Setup.exe'

    uninstall_flags: '/uninstall /x86 /x64 /q /norestart'
    msiexec: False
    locale: en_US
    reboot: False
  {% endfor %}

Example pillar data:
microsoft:
    dotnet:
        inst_ver: 4.7.03062
        pkg: NDP472-KB4054530
        sha256: c908f0a5bea4be282e35acba307d0061b71b8b66ca9894943d3cbb53cad019bc
        version: 4.7.2
HTH...

    Dirk
-- 
Dirk Heinrichs <dirk.he...@altum.de>
Matrix-Adresse: @heini:altum.de
GPG Public Key: 80F1540E03A3968F3D79C382853C32C427B48049
Privacy Handbuch: https://www.privacy-handbuch.de

Dirk Heinrichs

unread,
Dec 9, 2020, 10:58:41 AM12/9/20
to salt-...@googlegroups.com
Am 09.12.20 um 16:48 schrieb Dirk Heinrichs:
This is something we see for several packages on Windows. Our workaround is to use module.run instead. Here is our SLS for installing .Net:
...

Forgot the custom grain:
!/usr/bin/env python

import logging

from is_salt_master import _is_salt_master

try:
    # On newer versions
    from salt.utils.platform import is_windows
except Exception:
    # On older versions
    from salt.utils import is_windows

log = logging.getLogger(__name__)


def __virtual__():
    '''
    Only valid on minions
    '''
    return not _is_salt_master()


def dotnetversion():
    result = {}
    result['dotnetversion'] = 'None'
    try:
        if is_windows():
            # _winreg was renamed to winreg in P3
            try:
                import winreg
            except ImportError:
                import _winreg as winreg

            key = winreg.OpenKey(
                winreg.HKEY_LOCAL_MACHINE,
                r'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full')
            dotnetversion = winreg.QueryValueEx(key, "Version")[0]
            log.info("Setting dotnetversion to '{}'".format(dotnetversion))
            result['dotnetversion'] = dotnetversion
    except ValueError as e:
        log.exception(e)
    finally:
        return result


if __name__ == "__main__":
    print(dotnetversion())

Bye...

Edvinas Perminas

unread,
Dec 11, 2020, 6:53:19 AM12/11/20
to salt-...@googlegroups.com
Thanks Dirk, I'll try to test this asap!

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/4c2d8612-198d-3431-4801-f06cd7f597c7%40altum.de.
Reply all
Reply to author
Forward
0 new messages