使用所需的状态configuration(DSC)安装Web部署静默失败

DSC绝对是全新的,所以我现在真的很磕磕绊绊。 我有一个基本的configuration,确保安装IIS,.NET 4.5和MSMQ。 我正在努力configuration一个新的Windows 2012 R2实例来支持我们的应用程序。 目前我们的应用程序是通过使用PowerShell部署在Web Deploy上的(这些工件是用TeamCity中的PSake / MSBuild构build的)。

所以下一步,我正在尝试使用DSC来获取Web Deploy安装在目标服务器上。 这是一个MSI下载,而不是一个“Windowsfunction”,我可以简单地确保安装。

所以我在我的DSC中有一个自定义的Script ,它试图执行Web部署MSI文件的无人参与的安装。 剧本

 Script InstallWebDeploy { GetScript = { $false } SetScript = { $cmd = "MSIEXEC /a 'C:\Temp\WebDeploy_amd64_en-US.msi' /passive" # have also tried /qn (Start-Process -FilePath "msiexec.exe" -ArgumentList "/a 'C:\Temp\WebDeploy_amd64_en-US.msi' /passive" -Wait -Passthru).ExitCode } TestScript = { $false } } 

结果,生成.mof并使用它,给了我:

 VERBOSE: [CORAPP4]: LCM: [ Start Resource ] [[Script]InstallWebDeploy] VERBOSE: [CORAPP4]: LCM: [ Start Test ] [[Script]InstallWebDeploy] VERBOSE: [CORAPP4]: LCM: [ End Test ] [[Script]InstallWebDeploy] in 0.0000 seconds. VERBOSE: [CORAPP4]: LCM: [ Start Set ] [[Script]InstallWebDeploy] VERBOSE: [CORAPP4]: [[Script]InstallWebDeploy] Performing the operation "Set-TargetResource" on target "Executing the SetScript with the user supplied credential". VERBOSE: [CORAPP4]: LCM: [ End Set ] [[Script]InstallWebDeploy] in 1.0430 seconds. VERBOSE: [CORAPP4]: LCM: [ End Resource ] [[Script]InstallWebDeploy] VERBOSE: [CORAPP4]: LCM: [ End Set ] in 4.4783 seconds. VERBOSE: Operation 'Invoke CimMethod' complete. VERBOSE: Time taken for configuration job to complete is 4.214 seconds 

但是,Web Deploy不在服务器上的位置。 (我意识到Get-Script和Test-Script需要充实,但是想要减less这里涉及的variables的数量)

任何想法为什么这是失败? (但没有明显的错误?)

由于您使用DSC与MSI文件,我build议使用包资源。 然后,您可以确保它正在安装,而不是使用自定义脚本资源。 请注意,名称和产品ID属性必须与包装匹配。 我已经把一个基于你想要在下面安装的包的例子。

链接到包资源文档: 包资源MSDN

 WindowsFeature WebManagementService { Ensure = "Present" Name = "Web-Mgmt-Service" } Package WebDeploy { Ensure = "Present" Path = "$Env:SystemDrive\TestFolder\WebDeploy_amd64_en-US.msi" Name = "Microsoft Web Deploy 3.5" LogPath = "$Env:SystemDrive\TestFolder\logoutput.txt" ProductId = "1A81DA24-AF0B-4406-970E-54400D6EC118" Arguments = "LicenseAccepted='0' ADDLOCAL=ALL" }