简体   繁体   English

使用DSC cChocoPackageInstaller通过Chocolatey安装DotNet 4.6.1失败

[英]Failure Installing DotNet 4.6.1 via Chocolatey using DSC cChocoPackageInstaller

I'm attempting to set up a server Windows 2012 R2 in Azure via ARM templates and DSC. 我正在尝试通过ARM模板和DSC在Azure中设置服务器Windows 2012 R2。 The DSC script runs the cChocoPackageInstaller to install dotnet4.6.1 (after running the cChocoInstaller). DSC脚本运行cChocoPackageInstaller来安装dotnet4.6.1(在运行cChocoInstaller之后)。 It looks like this: 看起来像这样:

cChocoInstaller Choco
{
    InstallDir = "c:\choco"
}

cChocoPackageInstaller DotNet461 
{            
    Name = "dotnet-461" 
    DependsOn = "[cChocoInstaller]Choco" 
} 

The DotNet installer is downloaded but it ultimately fails when it is run. 下载了DotNet安装程序,但在运行时最终失败。 The log looks like this (I've excerpted just the errors here). 日志看起来像这样(我仅摘录了这里的错误)。

2016-06-17 13:05:52,001 [DEBUG] - Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe', statements: '/q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ' 
2016-06-17 13:05:52,001 [DEBUG] - Elevating Permissions and running ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ]. This may take a while, depending on the statements.
2016-06-17 13:05:52,110 [DEBUG] - Setting RunAs for elevation
2016-06-17 13:05:53,487 [INFO ] - The application cannot find one of its required files, possibly
2016-06-17 13:05:53,487 [INFO ] - 
2016-06-17 13:05:53,487 [INFO ] - because it was unable to create it in the folder. Please make
2016-06-17 13:05:53,487 [INFO ] - 
2016-06-17 13:05:53,487 [INFO ] - sure that the folder in which this application was downloaded is
2016-06-17 13:05:53,487 [INFO ] - 
2016-06-17 13:05:53,487 [INFO ] - accessible and not read-only.
2016-06-17 13:05:53,487 [INFO ] - 
2016-06-17 13:05:53,503 [DEBUG] - Command ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ] exited with '3'.
2016-06-17 13:05:53,518 [ERROR] - ERROR: Running ["C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\dotnet-461\4.6.01055.006\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" /q /norestart /log "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\chocolatey\net461.log" ] was not successful. Exit code was '3'. See log for possible error messages.
2016-06-17 13:05:53,518 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'c:\choco\helpers\chocolateyInstaller.psm1'; & 'c:\choco\helpers\chocolateyScriptRunner.ps1' -packageScript 'c:\choco\lib\dotnet-461\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '3'.
2016-06-17 13:05:53,534 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2016-06-17 13:05:53,549 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'

So a couple of things: 有几件事:

  • No log file is produced for the DotNet installer...so it doesn't look like it's successfully launching the installer. 没有为DotNet安装程序生成日志文件...因此,它似乎无法成功启动安装程序。
  • The installer package is definitely downloaded to the expected location. 安装程序包肯定已下载到预期位置。 Not sure why it would be able to download the installer to this directory but then later not access/run it. 不知道为什么它能够将安装程序下载到此目录,但是后来无法访问/运行它。
  • If I RDP onto the box and run the "choco install dotnet4.6.1" command as a local admin the package installs with no errors. 如果我将RDP放到包装盒上并以本地管理员身份运行“ choco install dotnet4.6.1”命令,则该软件包将正确安装。
  • I'm now running choco 0.9.10 but had the same issue with 0.9.9 我现在正在运行choco 0.9.10,但是在0.9.9中有同样的问题
  • I'm running the newer version of the dotnet4.6.1 installer (unapproved) that runs in /q (quite) mode instead of /passive. 我正在运行以/ q(完全)模式而不是/ passive运行的dotnet4.6.1安装程序的较新版本(未批准)。 I had the same issue in Passive mode. 我在被动模式下遇到了同样的问题。

Any ideas are appreciated. 任何想法表示赞赏。 Thanks! 谢谢!

Sorry about the delay. 很抱歉延迟。 So you need to have an automation account. 因此,您需要拥有一个自动化帐户。 I have modified my template deployment script to create the automation account, then with the Get-AzureRmAutomationRegistrationInfo cmdlet, i get the primary key and endpoint like so: 我已经修改了模板部署脚本以创建自动化帐户,然后使用Get-AzureRmAutomationRegistrationInfo cmdlet,我得到了主键和端点,如下所示:

$RegistrationInfo = Get-AzureRmAutomationRegistrationInfo `
    -ResourceGroupName $ResourceGroupName `
    -AutomationAccountName $AccountName

New-AzureRmResourceGroupDeployment `
    -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
    -ResourceGroupName $ResourceGroupName -TemplateFile $TemplateFile `
    -TemplateParameterFile $TemplateParametersFile `
    # extra params here
    -RegistrationKey ($RegistrationInfo.PrimaryKey | ConvertTo-SecureString -AsPlainText -Force) `
    -RegistrationUrl $RegistrationInfo.Endpoint `
    -AutomationAccountName $AccountName

Then in the template itself, you have an automation account there as well (name from param), and as child resources of that, a configuration and a compilation. 然后,在模板本身中,您在那里也有一个自动化帐户(来自param的名称),并且作为其子资源,配置和编译。

See here for automation account part of the template and the configuration. 请参阅此处以获取模板和配置的自动化帐户部分。 (I was doing the same thing v recently, with issues, but it works in the end.) As you can see, the configuration is a script that downloads .net installer and installs. (最近我在v上做了同样的事情,但有问题,但最终还是有效。)如您所见,配置是一个脚本,可以下载.net安装程序并进行安装。 FYI, this requires a reboot, so if you have anything else going on on the vm during deploy, you may get conflicts. 仅供参考,这需要重新启动,因此,如果在部署期间在虚拟机上进行任何其他操作,则可能会发生冲突。

Like I said, you can also do it with a custom script extension if you want. 就像我说的那样,如果需要,您还可以使用自定义脚本扩展名来实现。 Msft have a script on service profiler site that does it: Msft在服务探查器站点上具有执行此操作的脚本:

{
    "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.7",
        "autoUpgradeMinorVersion": false,
        "settings": {
            "fileUris": [ "https://serviceprofiler.azurewebsites.net/content/downloads/InstallNetFx46.ps1" ],
            "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File InstallNetFx46.ps1"
        },
        "forceUpdateTag": "RerunExtension"
    },
    "name": "CustomScriptExtensionInstallNet46"
}

Not saying this is the best answer possible, but this works both via Chocolatey (launched directly from a CustomScript ARM extension) or via DSC (using a pull server and a custom DSC module for .Net 4.6.1) when either is initiated from an ARM template. 并不是说这是最好的答案,但是,当从其中一个启动时,通过Chocolatey(直接从CustomScript ARM扩展启动)或DSC(使用拉网服务器和.Net 4.6.1的自定义DSC模块)都可以使用。 ARM模板。 Below is from my chocolateyInstall.ps1. 下面是我的ChocolateyInstall.ps1。 I'm basically manually conducting the install instead of relying on the chocolatey install functionality. 我基本上是手动执行安装,而不是依靠巧克力式安装功能。 This came from the following SO question which used this approach for 4.5.2. 这来自以下SO问题 ,该问题在4.5.2中使用了此方法。

Function IsInstalled {
    $ver = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Release
    return (!($ver -eq $null) -and ($ver -ge 394254))
}

if (IsInstalled) {
    Write-Host "Microsoft .NET Framework 4.6.1 or later is already installed"
}
else {
    $SourceURI = "https://download.microsoft.com/download/3/5/9/35980F81-60F4-4DE3-88FC-8F962B97253B/NDP461-KB3102438-Web.exe"
    $FileName = $SourceURI.Split('/')[-1]
    $BinPath = Join-Path $env:SystemRoot -ChildPath "Temp\$FileName"

    if (!(Test-Path $BinPath))
    {
        Invoke-Webrequest -Uri $SourceURI -OutFile $BinPath
    }

    write-verbose "Installing .Net 4.6.1 from $BinPath"
    write-verbose "Executing $Binpath /q /norestart"
    Sleep 5
    Start-Process -FilePath $BinPath -ArgumentList "/q /norestart" -Wait -NoNewWindow            
    Sleep 5
    Write-Verbose "DotNet 4.6.1 Install completed"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM