2

我之前遇到过 VS 总是在重建项目,但打开详细输出通常会立即告诉我为什么要重建。这次我得到了下面的输出,我无法弄清楚是什么触发了重建,或者“无法解析...引用的所有项目”的真正含义或我能做些什么。

有谁知道如何解释这个构建输出,所以我可以阻止这个项目一直重建?输出还有更多内容,但我只是复制了前 100 行

Build started...
Failed to resolve all items referenced by 'SkyCourt.Tests.Infrastructure\SkyCourt.Tests.Infrastructure.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'WebJobMembershipTypesDaily\WebJobMembershipTypesDaily.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.CourtBookingReports\SkyCourt.Tests.CourtBookingReports.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt\SkyCourt.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.Models\SkyCourt.Tests.Models.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.ClubService\SkyCourt.Tests.ClubService.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.UI\SkyCourt.UI.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SparkPost\SparkPost.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.App.Automapper\SkyCourt.App.Automapper.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.Api\SkyCourt.Tests.Api.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.App.ViewModels\SkyCourt.App.ViewModels.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.App.Api\SkyCourt.App.Api.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.App.Utilities\SkyCourt.App.Utilities.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.App.Models\SkyCourt.App.Models.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.InterCityLeagues\SkyCourt.Tests.InterCityLeagues.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.ClassLibraries\SkyCourt.Tests.ClassLibraries.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.Helpers.Signalr\SkyCourt.Tests.Helpers.Signalr.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.Helpers.Stripe\SkyCourt.Tests.Helpers.Stripe.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Infrastructure\SkyCourt.Infrastructure.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.ClubTeamLeagues\SkyCourt.Tests.ClubTeamLeagues.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'Resources\CommonResources.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
Failed to resolve all items referenced by 'SkyCourt.Tests.App\SkyCourt.Tests.App.csproj'. This message can typically be ignored. The issue may be resolved by fully restoring and building the solution. If the unresolved item is a project reference this can lead to an incomplete NuGet restore result and missing package references. To ensure that restore is able to find all projects verify that all projects are referenced correctly and exist on disk.
1>------ Build started: Project: SkyCourt.Infrastructure, Configuration: Debug Any CPU ------
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\$(MSBuildToolsVersion)\Microsoft.Common.props using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild
1>Property reassignment: $(MSBuildProjectExtensionsPath)="C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.Infrastructure\obj\" (previous value: "obj\") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Microsoft.Common.props (56,5)
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore\* using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>The "Configuration" property is a global property, and cannot be modified.
1>The "Platform" property is a global property, and cannot be modified.
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>The "Configuration" property is a global property, and cannot be modified.
1>The "Platform" property is a global property, and cannot be modified.
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Property reassignment: $(DefineCommonItemSchemas)="false" (previous value: "true") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets (12,5)
1>Property reassignment: $(DefineCommonCapabilities)="false" (previous value: "true") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets (13,5)
1>Property reassignment: $(DefineCommonReferenceSchemas)="false" (previous value: "true") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets (14,5)
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>The "Configuration" property is a global property, and cannot be modified.
1>The "Platform" property is a global property, and cannot be modified.
1>Property reassignment: $(_DebugSymbolsProduced)="true" (previous value: "false") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (150,5)
1>Property reassignment: $(_DocumentationFileProduced)="false" (previous value: "true") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (159,5)
1>The "DevEnvDir" property is a global property, and cannot be modified.
1>The "SolutionName" property is a global property, and cannot be modified.
1>The "SolutionFileName" property is a global property, and cannot be modified.
1>The "SolutionPath" property is a global property, and cannot be modified.
1>The "SolutionDir" property is a global property, and cannot be modified.
1>The "SolutionExt" property is a global property, and cannot be modified.
1>Property reassignment: $(ProcessorArchitecture)="msil" (previous value: "") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (490,5)
1>Property reassignment: $(DelaySign)="" (previous value: "false") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (530,5)
1>Property reassignment: $(_SGenGenerateSerializationAssembliesConfig)="Auto" (previous value: "") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (3530,5)
1>Property reassignment: $(_SGenGenerateSerializationAssembliesConfig)="Off" (previous value: "Auto") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (3531,5)
1>Property reassignment: $(_CodeAnalysisTreatWarningsAsErrors)="false" (previous value: "") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (125,5)
1>Property reassignment: $(PrepareForRunDependsOn)="
1>      CopyFilesToOutputDirectory
1>    ;RunCodeAnalysis" (previous value: "
1>      CopyFilesToOutputDirectory
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (167,9)
1>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild;$(MSBuildProgramFiles32)\MSBuild
1>Property reassignment: $(ResolveReferencesDependsOn)="
1>      
1>      BeforeResolveReferences;
1>      AssignProjectConfiguration;
1>      ResolveProjectReferences;
1>      FindInvalidProjectReferences;
1>      ResolveNativeReferences;
1>      ResolveAssemblyReferences;
1>      GenerateBindingRedirects;
1>      ResolveComReferences;
1>      AfterResolveReferences
1>    ;
1>      ImplicitlyExpandDesignTimeFacades
1>    " (previous value: "
1>      BeforeResolveReferences;
1>      AssignProjectConfiguration;
1>      ResolveProjectReferences;
1>      FindInvalidProjectReferences;
1>      ResolveNativeReferences;
1>      ResolveAssemblyReferences;
1>      GenerateBindingRedirects;
1>      ResolveComReferences;
1>      AfterResolveReferences
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.NETFramework.CurrentVersion.targets (75,5)
1>Property reassignment: $(PrepareResourceNamesDependsOn)="
1>                    AssignWinFXEmbeddedResource;
1>                    
1>      AssignTargetPaths;
1>      SplitResourcesByCulture;
1>      CreateManifestResourceNames;
1>      CreateCustomManifestResourceNames
1>    
1>      " (previous value: "
1>      AssignTargetPaths;
1>      SplitResourcesByCulture;
1>      CreateManifestResourceNames;
1>      CreateCustomManifestResourceNames
1>    ") at C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets (97,7)

更新

在按照 Perry 的建议执行 update-package -reinstall 并打开诊断输出(我以为我有)之后,我可以看到重建项目的真正原因是:

1>Project 'SkyCourt.Tests.Helpers.MVC' is not up to date. CopyLocal reference 'C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.Tests.Helpers.MVC\bin\Debug\System.Security.Cryptography.Algorithms.dll' is missing from output location.

奇怪的是,为这个项目安装了 System.Security.Cryptography.Algorithms。在引用上, CopyLocal 标志为真。

这个 dll 应该放在我的磁盘上的什么位置,应该复制到哪里?

看来我需要这个包,因为 System.Net.Http 需要它并将其拉入。

最终更新

我相信这种不断重建的开始是因为在我的一个项目中,编译器建议我需要添加 System.Net.Http 以满足对 HTTP 上下文的引用。但是,这是错误的做法,会导致其中一种 DLL 没有被复制到输出目录。相反,我应该添加对 Microsoft.AspNet.WebApi 的引用。当我这样做时,它解决了这个问题。是对帮助我找到答案的 SO 答案的参考。

然后一些其他项目引用了 System.Data(我可以从 NuGet 包管理器中删除)和一些其他 System.* 组件,这些组件实际上由 mscor.lib 或类似的东西提供。这是一个非常繁琐的构建过程,需要启用诊断输出以查看缺少哪些 dll,然后确定如何处理每个 dll。诊断输出导致构建速度至少慢 5 倍。

最后一件事,如果您在运行时发现这些 Dll 未找到,则可能是由于. 您需要删除您可能在 app.config 中为该 GitHub 问题列表中的 dll 提供的任何绑定重定向。这些 dll 现在是 .Net 的一部分,不再作为单独的 dll 发布。

4

2 回答 2

1

正如我的评论所说:

从描述中,请仔细检查您的项目引用、nuget 包引用和程序集引用。问题是其中一个丢失了,导致无法找到 dll。所以重建总是在进行。

所以请尝试以下步骤:

1)进入Tools --> Options --> Nuget Package Manager --> General然后勾选这两个选项

在此处输入图像描述

2)如果您的项目有任何非 sdk 网络框架项目,您必须在Tools --> Nuget Package Manager --> Package Manager Console下运行这些命令:

update-package -reinstall

3)检查您的解决方案下的所有项目,确保项目引用都存在,或者您可以删除项目引用然后重新添加它们。

另外,请检查添加引用下是否有任何程序集dll ,请确保它们存在并使用正确hintpath。此外,请确保您没有引用任何废弃的 nuget 包。

之后,首先重建您的解决方案。然后,单击构建以检查它是否为up-to-date.

此外,如果您想查看重建的原因,可以将 Build Project 输出日志设置为Diagnostic。像这样:

在此处输入图像描述

最终更新-----由于问题 dll

我相信这种不断的重建开始了,因为在我的一个项目中,编译器建议我需要添加System.Net.Http以满足对 HTTP 上下文的引用。但是,这是错误的做法,会导致其中一种 DLL 没有被复制到输出目录。相反,我应该添加对Microsoft.AspNet.WebApi. 当我这样做时,它解决了这个问题。是对帮助我找到答案的 SO 答案的参考。

然后一些其他项目引用了System.Data(我可以从 NuGet 包管理器中删除)和一些其他 System.* 组件,这些组件实际上由 mscor.lib 或类似的东西提供。这是一个非常繁琐的构建过程,需要启用诊断输出以查看缺少哪些 dll,然后确定如何处理每个 dll。诊断输出导致构建速度至少慢 5 倍。

最后一件事,如果您在运行时发现这些 Dll 未找到,则可能是由于. 您需要删除您可能在 app.config 中为该 GitHub 问题列表中的 dll 提供的任何绑定重定向。这些 dll 现在是其中的一部分,.Net不再作为单独的 dll 发布。

于 2021-03-04T06:52:00.353 回答
0

在将 Net5 xunit 测试项目添加到以前仅包含 Framework 4.8 项目(具有旧版 .csproj 格式)的解决方案后,我遇到了“无法解析 .csproj 中引用的所有项目”。

主项目使用 nuget.config 指向解决方案级别的 .nuget 目录(通过“repositoryPath”键)——它一直运行良好。同时,测试项目正在使用我的 Windows 配置文件夹中的默认包文件夹。

在解决方案的 nuget.config 中为测试项目添加另一个条目(通过“globalPackagesFolder”键)将两个项目设置为在同一位置查找包,并且警告消失了。

不完全确定发生了什么,但似乎有些东西在那里变得混乱。现在一切都好。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value=".nuget" />
    <add key="globalPackagesFolder" value=".nuget" />
  </config>
</configuration>
于 2021-05-06T04:23:50.853 回答