2017-01-18 10 views
0

開発環境を簡単に設定できるように、Powershell DSCスクリプトを作成しています。私はGUIを開かずにVisual Studio 2012アドオンをインストールしようとしています。Visual Studio 12 VSIXInstallerはDSCスクリプトで実行中にFileNotFoundExceptionを報告します

Specflow .vsixファイルをダウンロードしました。実行時にPowershellコマンドプロンプトで

& "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VSIXInstaller.exe" /q C:\Users\Public\Downloads\TechTalk.SpecFlow.Vs2010Integration.vsix 

を実行すると、問題なく動作します。しかし、私がDSC Scriptリソースで同じことをしようとすると、問題が発生します。上記のコマンドをコピーしてSetScriptに貼り付けてVSInstaller.exeを実行すると、コマンドは決して終了しません。

が、私はそれゆえチョコInstall-VSIXコマンドレットに基づいて、次のことを試してみました:この場合

Script installSpecflowVS { 
     SetScript = {   
      $specUrl = 'https://visualstudiogallery.msdn.microsoft.com/9915524d-7fb0-43c3-bb3c-a8a14fbd40ee/file/79327/7/TechTalk.SpecFlow.Vs2010Integration.vsix' 
      $outfile = 'C:\Users\Public\DownloadsTechTalk.SpecFlow.Vs2010Integration.vsix' 
      wget $specUrl -outfile $outfile 
      $psi = New-Object System.Diagnostics.ProcessStartInfo 
      $psi.FileName='C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VSIXInstaller.exe' 
      $psi.Arguments="/q $outfile" 
      $s = [System.Diagnostics.Process]::Start($psi) 
      $s.WaitForExit() 
      return $s.ExitCode 
     } 
     TestScript = { return $False } 
     GetScript = { return $True } 
} 

、コマンドは完了しますが、VSIXInstall.exeは私が中に作成されたログから見ることができますするFileNotFoundエラーがスローされますC:\ Windows \ Temp \

1/18/2017 10:51:51 AM - Searching for applicable products... 
1/18/2017 10:51:51 AM - Found installed product - Microsoft Visual Studio Professional 2012 
1/18/2017 10:51:51 AM - System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) 
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) 
    at Microsoft.VisualStudio.Settings.ExternalSettingsManager.GetScopePaths(String applicationPath, String suffixOrName, String vsVersion, Boolean isLogged, Boolean isForIsolatedApplication) 
    at Microsoft.VisualStudio.Settings.ExternalSettingsManager.CreateForApplication(String applicationPath) 
at VSIXInstaller.App.GetExtensionManager(SupportedVSSKU sku) 
at VSIXInstaller.App.GetExtensionManagerForApplicableSKU(SupportedVSSKU supportedSKU, IInstallableExtension installableExtension, List`1 applicableSKUs) 
at VSIXInstaller.App.InitializeInstall() 
at VSIXInstaller.App.OnStartup(StartupEventArgs e) 

ファイルが存在します。私は何かをVSInstallerを供給する場合には、それが代わりに

1/18/2017 10:21:45 AM - VSIXInstaller.InvalidCommandLineException: Path to vsix file 'outfile' is invalid or you don't have required access permissions. Please check the path is valid and you have required access permissions. 

スクリプトはPowerShellの私が管理してPowerShellのISEを使用して、それを実行しています。5.でWindows 7 SP1の仮想マシン上でローカルに実行されている次のエラーを与える存在しません。特権。

明らかに、DSCセットスクリプトを使用して実行されているスクリプトについては、何か異なっています。任意のアイデアを修正する方法を修正するには?それをやる別の方法?

答えて

0

VSIXは、ユーザーごとに、どのユーザーにPSDscRunAsCredential(PowerShell 5.0で追加)を使用してインストールするかをDSCに伝える必要があります。

例ここで、$credentialは、VSIXをインストールするユーザーの資格情報です。

Script installSpecflowVS { 
     SetScript = {   
      $specUrl = 'https://visualstudiogallery.msdn.microsoft.com/9915524d-7fb0-43c3-bb3c-a8a14fbd40ee/file/79327/7/TechTalk.SpecFlow.Vs2010Integration.vsix' 
      $outfile = 'C:\Users\Public\DownloadsTechTalk.SpecFlow.Vs2010Integration.vsix' 
      wget $specUrl -outfile $outfile 
      $psi = New-Object System.Diagnostics.ProcessStartInfo 
      $psi.FileName='C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VSIXInstaller.exe' 
      $psi.Arguments="/q $outfile" 
      $s = [System.Diagnostics.Process]::Start($psi) 
      $s.WaitForExit() 
      return $s.ExitCode 
     } 
     TestScript = { return $False } 
     GetScript = { return $True } 
     PSDscRunAsCredential = $credential 
} 

また、あなたの資格情報を漏洩しないように適切にMOFファイルを暗号化する方法についてSecuring the MOF Fileを参照してください。

関連する問題