最近的例行更新破坏了我的一个项目的编译。
出现许多错误,包括:Areas\HelpPage\ApiDescriptionExtensions.cs could not be found
在进行项目范围内的搜索时,未找到对这些文件的引用。

根据源代码控制,packages.config中发生了以下更改:

-   <package id="Microsoft.AspNet.Mvc" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.Razor" version="3.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebApi" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebApi.Client" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebApi.Core" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.1" targetFramework="net45" />
-   <package id="Microsoft.AspNet.WebPages" version="3.1.1" targetFramework="net45" />
+   <package id="Microsoft.AspNet.Mvc" version="5.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.Razor" version="3.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
+   <package id="Microsoft.AspNet.WebApi" version="5.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.WebApi.Client" version="5.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.WebApi.Core" version="5.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.2" targetFramework="net45" />
+   <package id="Microsoft.AspNet.WebPages" version="3.1.2" targetFramework="net45" />

为什么例行库更新导致与看似无关的文件有关的错误,
以及如何解决? (问答格式)

最佳答案

我对文件之一ApiDescriptionExtensions的名称执行了内部文件内容搜索,该文件返回了对我的.csproj文件的引用。

解决编译器错误的方法是从.csproj中删除对有问题的文件的引用(下面显示了特定的引用)。

我怀疑Microsoft.AspNet.WebApi.HelpPage的安装由于文件名而导致了问题,但是由于此类文件不突然存在而中断了构建,这似乎是Microsoft或NuGet软件包维护者甚至需要修复的错误。如果此类文件在项目创建时就存在,后来又删除了。

删除以下.csproj行可重新构建项目:

<Compile Include="Areas\HelpPage\ApiDescriptionExtensions.cs" />
<Compile Include="Areas\HelpPage\App_Start\HelpPageConfig.cs" />
<Compile Include="Areas\HelpPage\Controllers\HelpController.cs" />
<Compile Include="Areas\HelpPage\HelpPageAreaRegistration.cs" />
<Compile Include="Areas\HelpPage\HelpPageConfigurationExtensions.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\DictionaryModelDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\EnumTypeModelDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\EnumValueDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\IModelDocumentationProvider.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\KeyValuePairModelDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ModelDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ModelDescriptionGenerator.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ModelNameAttribute.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ModelNameHelper.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ParameterAnnotation.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\ParameterDescription.cs" />
<Compile Include="Areas\HelpPage\ModelDescriptions\SimpleTypeModelDescription.cs" />
<Compile Include="Areas\HelpPage\Models\HelpPageApiModel.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\HelpPageSampleGenerator.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\HelpPageSampleKey.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\ImageSample.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\InvalidSample.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\ObjectGenerator.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />

如您所见,只需删除包含对Areas\HelpPage的引用的每一行

08-15 23:29