2016-04-25 50 views
0

我正在使用Visual Studio 2015,我有兩種不同的Web應用程序的解決方案。它下面有一個解決方案和兩個項目。與金塊的文件分佈爲:VSTS持續集成:此計算機上缺少NuGet包

  1. 包文件夾是在解決方案目錄
  2. Package.config在每個項目目錄

沒有金塊文件夾:nugget.config和金塊。 exe在我的解決方案。

This project references NuGet package(s) that are missing on this computer. Use 
 
NuGet Package Restore to download them. For more information, see The missing file is 
 
..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props.

我的項目建設,並在Visual Studio中運行很好,但我使用VSTS持續集成生成解決方案步驟(使用映射到一個項目中構建定義),它給時面臨的一個問題

這是MyProject.csproj文件:

<?xml version="1.0" encoding="utf-8"?> 
 
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
 
    <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" /> 
 
    <Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" /> 
 
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> 
 
    <PropertyGroup> 
 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
 
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
 
    <ProductVersion> 
 
    </ProductVersion> 
 
    <SchemaVersion>2.0</SchemaVersion> 
 
    <ProjectGuid>{BBD26A49-D1F4-4391-9D60-2469433DEE0D}</ProjectGuid> 
 
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 
 
    <OutputType>Library</OutputType> 
 
    <AppDesignerFolder>Properties</AppDesignerFolder> 
 
    <RootNamespace>AdminUI</RootNamespace> 
 
    <AssemblyName>AdminUI</AssemblyName> 
 
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> 
 
    <MvcBuildViews>false</MvcBuildViews> 
 
    <UseIISExpress>true</UseIISExpress> 
 
    <IISExpressSSLPort /> 
 
    <IISExpressAnonymousAuthentication /> 
 
    <IISExpressWindowsAuthentication /> 
 
    <IISExpressUseClassicPipelineMode /> 
 
    <UseGlobalApplicationHostFile /> 
 
    <SccProjectName>SAK</SccProjectName> 
 
    <SccLocalPath>SAK</SccLocalPath> 
 
    <SccAuxPath>SAK</SccAuxPath> 
 
    <SccProvider>SAK</SccProvider> 
 
    <NuGetPackageImportStamp> 
 
    </NuGetPackageImportStamp> 
 
    </PropertyGroup> 
 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

我注意到,它只是試圖導入產生錯誤的包,但它並沒有明確導入其他包,但它們作爲參考:

<Reference Include="WebGrease"> 
 
     <Private>True</Private> 
 
     <HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath> 
 
    </Reference> 
 
    <Reference Include="Antlr3.Runtime"> 
 
     <Private>True</Private> 
 
     <HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath> 
 
    </Reference>

這也是myProject.csproj文件的末尾:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> 
 
    <PropertyGroup> 
 
     <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> 
 
    </PropertyGroup> 
 
    <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" /> 
 
    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" /> 
 
    </Target>

我很奇怪,爲什麼它給這個錯誤,考慮到這個包已經安裝在前面的步驟「掘金安裝」。爲什麼找不到它?我在這個問題上花了很多時間!

回答

0

其實,這個工作對我來說:

添加映射(存儲庫配置)的包文件夾中的解決方案

庫配置

enter image description here

Nuget安裝配置

enter image description here

然後,它像一個魅力。

1

在添加構建任務之前,您可以添加nuget安裝或還原任務。這將在構建代理上恢復/安裝nuget軟件包。

+0

我已經嘗試了兩種,但生成不同的錯誤。當我指定安裝時發生此錯誤,此任務的「解決方案路徑」指向項目目錄中的「packages.config」。 – Coding

+0

您可以在「解決方案的路徑或packages.config」中最好添加**/*。sln,並將'NuGet.config的路徑'留空。 – Peter