2017-07-18 8 views
0

を読み込まないVCBuild返しますのPowerShellからのMSBuildを使用すると、私はいくつかのVisual StudioでのPowerShellスクリプトから2005のソリューションをビルドを起動しようとしていると、それはこのエラーを返し、エラーが

 
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location 
of the component to the system path if it is installed elsewhere. [C:\path\to\solution\solutionToBuild.sln] 
Done Building Project "C:\path\to\solution\solutionToBuild.sln" (default targets) -- FAILED. 

Build FAILED. 

"C:\path\to\solution\solutionToBuild.sln" (default target) (1) -> 
(solutionToBuild target) -> 
    MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the locati 
on of the component to the system path if it is installed elsewhere. [C:\path\to\solution\solutionToBuild.sln] 

    0 Warning(s) 
    1 Error(s) 

Time Elapsed 00:00:00.84 

私は本当に理由は分かりません私はMSVS 2005がインストールされているので、このメッセージが返され、私は、.NET V2がインストールされている:

 
PSChildName      Version  Release Product 
-----------      -------  ------- ------- 
v2.0.50727      2.0.50727.5420     
v3.0        3.0.30729.5420     
Windows Communication Foundation 3.0.4506.5420     
Windows Presentation Foundation 3.0.6920.5011     
v3.5        3.5.30729.5420     
Client       4.6.01590  394806 4.6.2 
Full        4.6.01590  394806 4.6.2 
Client       4.0.0.0      

それは私が私のシステム環境パスに何かを追加する必要がありますが、エラー・メッセージが追加して何を言っていないということかもしれません私はここで少し迷っています。

+1

私が正しく覚えていれば、これはコマンドラインビルド環境を起動していないときのエラーです。 VS2005はかなり古く、私はそれがインストールされていません。ビルド環境でこれを起動するためのbatファイルはおそらくC:\ Program Files(x86)\ Microsoft Visual Studio xx \ CommonX \ Tools \ VsMSBuildCmd.batの下にあります。 もちろん、 'X'バージョンは2005年に表示されます –

+0

おそらく@DavidDaughertyが言うことでしょう。 PATHなどが正しく設定されていない場合は、おそらく 'msbuild solutionToBuild.sln'を実行できません。例えばここで2番目と3番目の答え:https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt – stijn

答えて

0

だから、私は完全に書いた機能を変更することになったとここで私は(私のために働いている)思い付いたものです:

function Build-MSVS2K5Solution { 
    param (
     [parameter(mandatory=$true)][validateNotNullOrEmpty()][String] $solutionToBuild, 
     [parameter(mandatory=$true)][validateNotNullOrEmpty()][Array] $solutionEnv, 
     [parameter(mandatory=$false)][validateNotNullOrEmpty()][Switch] $autoOpenBuildLog = $false 
    ) 

    process { 
     $wshell = New-Object -ComObject Wscript.Shell 
     $wshell.Popup("Please wait while solutions are being rebuilt.",0,"Building Solution...",0x1) 
     cd "C:\" 
     if (Test-Path "C:\Windows\Microsoft.NET\Framework\v2.0.50727") 
     { 
      $msBuild = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe" 
     } 

     $buildArgs = $solutionToBuild + (Get-ChildItem $SolutionToBuild | Where { $_.Name -like "*.sln" }) +" /p:Configuration=Debug /p:Platform=Win32" 
     $buildLog = [Environment]::GetFolderPath("Desktop") + "\buildlog.log" 

     foreach ($solEnv in $solutionEnv) { 
      $itemPath = "env:" + $solEnv.Substring(0, ($solEnv.ToString().LastIndexOf("="))) 
      $itemValue = $solEnv.Substring(($solEnv.ToString().LastIndexOf("=")+1)) 
      Set-Item -Path $itemPath -Value $itemValue 
     } 


     Write-Output "Building $buildArgs..." 
     Start-Process -FilePath $msBuild -ArgumentList $buildArgs -RedirectStandardOutput $buildLog 

     if ($autoOpenBuildLog) 
     { 
      Write-Output "Getting content of : $buildLog" 
      Get-Content $buildLog -Tail 1 -Wait 
     } 
    } 
} 

$solutionEnv = "envName=envValue", "envName2=envValue2", "etc.=etc." 
Build-MSVS2K5Solution -SolutionToBuild "C:\Path\to\solution\" -solutionEnv $solutionEnv -autoOpenBuildLog 

それは完璧ではないのですが、それは動作します。基本的に、私は解決策にパスを送り、関数は "* .sln"という解決策を見つけます(私は解決策には1つしか含まれていません)。これは、文字列に受け取った環境変数を設定し、ビルドを開始し、$ autoOpenBuildLogが呼び出されると、buildLogがpowershellプロンプトに表示されます。

コードを改善するためのご提案がありましたら教えてください。

ありがとうございました@David Daughertyと@stijn!

関連する問題

 関連する問題