2013-09-27 6 views
7

Spero che qualcuno possa aiutare a diagnosticare cosa sta andando storto con la mia build. Sto usando Visual Studio 2012, NuGet 2.7, & Servizio TFS (git). Sono stato in grado di aggirare il seguente errore:NuGet Pacchetto errore mancante durante il tentativo di utilizzare TFS Servicice

"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj (361): This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." 

Ho permesso a ripristinare il pacchetto di funzionalità (ma credo di aver sentito con NuGet 2.7 non importa). In ogni modo ho trovato un blog utile su questo problema: Blog Article

Qui è il mio attuale script di build:

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" 
     DefaultTargets="Build" 
     xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

    <PropertyGroup> 
    <OutDir>$(MSBuildThisFileDirectory)bin</OutDir> 
    <Configuration>Release</Configuration> 
    <ProjectProperties> 
     OutDir=$(OutDir); 
     Configuration=$(Configuration); 
    </ProjectProperties> 
    </PropertyGroup> 

    <ItemGroup> 
    <Solution Include="$(MSBuildThisFileDirectory)src\*.sln" /> 
    </ItemGroup> 

    <Target Name="RestorePackages"> 
    <Exec Command="&quot;$(MSBuildThisFileDirectory)src\.nuget\NuGet.exe&quot; restore &quot;%(Solution.Identity)&quot;" /> 
    </Target> 

    <Target Name="Clean"> 
    <MSBuild Targets="Clean" 
      Projects="@(Solution)" 
      Properties="$(ProjectProperties)" /> 
    </Target> 

    <Target Name="Build" DependsOnTargets="RestorePackages"> 
    <MSBuild Targets="Build" 
      Projects="@(Solution)" 
      Properties="$(ProjectProperties)" /> 
    </Target> 

    <Target Name="Rebuild" DependsOnTargets="RestorePackages"> 
    <MSBuild Targets="Rebuild" 
      Projects="@(Solution)" 
      Properties="$(ProjectProperties)" /> 
    </Target> 

</Project> 

e qui è il mio log di compilazione:

Build started 9/27/2013 1:01:14 AM. 
Project "C:\a\src\build.proj" on node 1 (default targets). 
RestorePackages: 
    "C:\a\src\src\.nuget\NuGet.exe" restore "C:\a\src\src\RecipeDb.sln" 
Project "C:\a\src\build.proj" (1) is building "C:\a\src\src\RecipeDb.sln" (2) on node 1 (Build target(s)). 
ValidateSolutionConfiguration: 
    Building solution configuration "Release|Any CPU". 
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (3) on node 1 (default targets). 
C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj(361,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567. 
Done Building Project "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default targets) -- FAILED. 
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (5) on node 1 (default targets). 
C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567. 
Done Building Project "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default targets) -- FAILED. 
Done Building Project "C:\a\src\src\RecipeDb.sln" (Build target(s)) -- FAILED. 
Done Building Project "C:\a\src\build.proj" (default targets) -- FAILED. 

Build FAILED. 

"C:\a\src\build.proj" (default target) (1) -> 
"C:\a\src\src\RecipeDb.sln" (Build target) (2) -> 
"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default target) (3) -> 
(EnsureBclBuildImported target) -> 
    C:\a\src\src\RecipeDb.M 
vc\RecipeDb.Mvc.csproj(361,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567. 


"C:\a\src\build.proj" (default target) (1) -> 
"C:\a\src\src\RecipeDb.sln" (Build target) (2) -> 
"C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default target) (5) -> 
    C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567. 

    0 Warning(s) 
    2 Error(s) 

Time Elapsed 00:00:09.21 

così ho copiato la sua corporatura registra e ha appena modificato il percorso in cui si trova nuget.exe. Il comando Nuget.exe sembra essere in esecuzione ma a quanto pare non sta scaricando i pacchetti. Naturalmente la costruzione a livello locale funziona bene (anche se si elimina la directory di pacchetti

risposta

4

Come posso vedere nel link nella linea messaggio di errore che hai postato:.

C'è un miglioramento Nuget 2.7 come di seguito:

The Improvement

We’ve updated Microsoft.Bcl.Build to use a different approach. The new version will use a conditional import similar to what NuGet’s automatic import feature does . This will always allow the project to load in Visual Studio.

However, Microsoft.Bcl.Build also adds a target to your project that will run after the build is finished. This target checks whether the current build restored packages and if so fail the build with an actionable error message:

Package Restore Error

The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568 .

Building a second time will fix this error. Please note that this error will only appear if packages were missing so it’s not like you always have to build twice.

Tuttavia, al di sotto che dice che non affronterà/scenari di server di build di integrazione continua (CI) e ha bisogno di una soluzione come specificato nel seguente estratto dall'articolo:

This solution doesn’t address build server/continuous integration (CI) scenarios. In order to successfully use package restore on the build server, you have two options:

  1. Check-in the .targets file.
  2. Explicitly run NuGet package restore prior to building your project/solution.

Spero che il problema che stai affrontando sia anche per questo solo.

+1

@James, penso che sia stato un complimento. Ho appena pubblicato la parte dal link che stava cercando di essere utile per risolvere il problema. È prassi comune in StackOverflow pubblicare la parte richiesta dai collegamenti che stai postando perché il contenuto del link potrebbe essere mutilato in futuro, ma anche questi post dovrebbero essere significativi. – RinoTom

+2

Costruire due volte non funziona per me :(Ottengo lo stesso errore due volte: '" C: \ percorso \ progetto.csproj "(destinazione predefinita) (4) -> (destinazione AssicuratoBclBuildImported) -> C: \ percorso \ project.csproj (142,5): errore: questo progetto fa riferimento a pacchetti NuGet mancanti su questo computer. Abilitare NuGet Package Restore per scaricarli. Per ulteriori informazioni, vedere http://go.microsoft.com/ fwlink /? LinkID = 317567. –

1

Per me il riferimento a Microsoft.Bcl.Build e BeforeTargets = "BeforeBuild" causava problemi. Questo è stato aggiunto quando Microsoft.Bcl.Build è stato aggiunto come dipendenza a un pacchetto Azure Nuget. Prova a controllare il file di progetto e rimuovendolo.

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" /> 
    <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''"> 
    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" /> 
    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> 
    </Target> 
+0

La stessa cosa per me. Ho modificato i file .csproj (diversi progetti) e rimosso quella parte relativa a Bcl. Ciò risolveva il problema. – jbarrameda