2015-06-14 51 views
10

我有一個C#項目,其目標框架設置爲.NET 4.5。出於某種奇怪的原因,所有引用都標有黃色警告三角形,如下所示。 我試過卸載並重新加載項目。我什至試圖手動重新添加一個系統引用無濟於事。項目中所有引用的Visual studio 2013黃色警告

enter image description here

我得到的警告是:

警告13引用的組件 'AutoMapper' 找不到。 Services.Contracts警告14找不到引用的組件 'AutoMapper.Net4'。 Services.Contracts 警告15找不到引用的組件'log4net'。 Services.Contracts警告16找不到引用的組件 'Mindscape.LightSpeed'。 Services.Contracts 警告17找不到引用的組件'Mindscape.LightSpeed.Linq' 。 Services.Contracts警告18找不到引用的組件 'System'。 Services.Contracts警告19找不到引用組件'System.Core' 。 Services.Contracts警告25找不到引用的組件'System.Data' 。 Services.Contracts警告24無法找到引用的 組件'System.Data.DataSetExtensions'。 Services.Contracts警告20找不到引用的組件 'System.Runtime.Serialization'。 Services.Contracts 警告21找到的引用組件'System.ServiceModel'不能爲 。 Services.Contracts警告22找不到引用的組件 'System.ServiceModel.Web'。 Services.Contracts 警告26找不到引用的組件'System.Xml'。 Services.Contracts警告23找不到引用的組件 'System.Xml.Linq'。 Services.Contracts

發生了什麼,我該如何解決這個問題?

+0

你確實有.Net 4.5嗎? –

+0

是的。此外,解決方案中的所有其他項目都將目標框架設置爲4.5並編譯正常。 –

+0

不知道項目的年齡,但那些引用的程序集版本是什麼? –

回答

28

我有同樣的問題,我從.csproj文件中刪除了以下條目,它解決了我的問題。

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> 
<PropertyGroup> 
    <ErrorText>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=322105. The missing file is {0}.</ErrorText> 
</PropertyGroup> 
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /></Target> 
+1

爲我工作(VC2015&resharper 10) – y0uri

+1

看來你使用的是解決方案級別的nuget管理,導致Nuget.Targets文件相對於解決方案(.sln)文件,並且您現在試圖加載其中一個項目(.csproj)轉換爲不同的解決方案。所以它沒有找到Nuget.Targets。 – redcalx

0

刪除「EnsureNugetPackageBuildImports可以工作,但根本原因,正如@redcalx指出:Nuget.Targets文件丟失。

我閉上我的解決方案,並創建一個名爲.nuget 然後從另一個文件夾複製的文件夾:

  • NuGet.targets
  • NuGet.Config

注:在我的nuget.config我有一個repositoryPath節點,指向c:\ packages \,這有助於將我的解決方案的所有包保存在一個文件夾中。

請記住,每次開始複製您的.nuget文件夾的新解決方案。

相關問題