简体   繁体   English

Visual Studio 2017反复建立项目

[英]Visual Studio 2017 is building project over and over again

I have a big solution (~ 450 projects), where some projects are building over and over again, although I haven't changed anything. 我有一个很大的解决方案(〜450个项目),其中有些项目一遍又一遍地建立,尽管我没有做任何更改。

When I change build output verbosity to diagnostic it says: 当我将生成输出的详细程度更改为diagnostic它说:

Project 'ProjectA' is not up to date. 项目“ ProjectA”不是最新的。 Missing input file 'C:\\Src\\Project.Core\\Bin\\Release\\ProjectB.dll' 缺少输入文件'C:\\ Src \\ Project.Core \\ Bin \\ Release \\ ProjectB.dll'

ProjectA dependes on ProjectB and I'm building configuration Debug , so why is Visual Studio checking for the file ProjectB.dll in the Release -folder? ProjectA依赖于ProjectB而我正在构建配置Debug ,那么Visual Studio为什么要在Release -folder中检查文件ProjectB.dll ProjectB.dll gets built and copied in the correct folder (debug)! ProjectB.dll构建并复制到正确的文件夹中(调试)!

The output path is the same for every project (c# and c++): 每个项目(c#和c ++)的输出路径都相同:

<OutputPath>$(SolutionDir)Bin\$(Configuration)\</OutputPath>

This is just an example. 这只是一个例子。 Multiple projects in my solution have this weird behavior. 我的解决方案中的多个项目都有这种奇怪的行为。 Seems like the c++ projects are causing this, but I have no clear evidence. 似乎是c ++项目造成了这种情况,但是我没有明确的证据。

Here are my Process Monitor analysis of the file accesses: 这是我对文件访问的Process Monitor分析:

在此处输入图片说明

UPDATE 1: 更新1:

ProjectA (C# project) references ProjectB (C++ project) using a ProjectReference : ProjectA(C#项目)使用ProjectReference引用ProjectB(C ++项目):

<ProjectReference Include="..\..\ProjectB.vcxproj">
   <Project>{F2F4C146-8A98-432B-BB9F-A06C4B4162CF}</Project> 
   <Name>ProjectB</Name>
</ProjectReference>

UPDATE 2: 更新2:

There's this setting for .NET Core projects: .NET Core项目具有以下设置:

在此处输入图片说明

Is there something similar for projects targeting .NET Framework? 针对.NET Framework的项目是否有类似内容?

UPDATE 3: 更新3:

Seems like the code for the FastUpToDateCheck for C#-projects is in the csproj.dll assembly. 似乎用于c#项目的FastUpToDateCheck的代码在csproj.dll程序csproj.dll Since it's a native assembly, I can't look into the code. 由于它是本机程序集,因此我无法查看代码。 That's a pity. 太可惜了。

The problem is not all of your projects are in the solution file ( .sln). 问题不在于您的所有项目都在解决方案文件( .sln)中。 Given that you are using project references. 假设您正在使用项目引用。 ie <ProjectReference <ProjectReference
When some of the projects are in the solution file ( .sln), and they reference another project outside of the solution file, MSBuild will build the other project, but not with the configuration you are building. 当某些项目在解决方案文件( .sln)中,并且它们引用解决方案文件之外的另一个项目时,MSBuild将构建另一个项目,但不使用您正在构建的配置。 It always or usually (a bug) will build using the opposite configuration you are using. 它总是或通常(错误)将使用与您使用的相反的配置来生成。

Super Duper annoying bug btw. 超级Duper烦人的bug顺便说一句。

As a work-around you could just declare an ItemGroup with all your projects, and just pass that straight to MSBuild and not use a solution at all. 解决方法是,您可以声明所有项目的ItemGroup,然后直接将其传递给MSBuild,而不使用任何解决方案。

<ItemGroup>
   <Files Include="**\*.csproj" />
   <Files Include="**\*.vcxproj" />
</ItemGroup>

<Target Name="Build">
   <MSBuild Projects="@(Files)" Properties="Configuration=Debug" />
</Target>

If they all use <ProjectReference , then MSBuild will automatically determine the order that they get built in. 如果它们都使用<ProjectReference ,则MSBuild将自动确定它们的内置顺序。

Or you could just create a solution that has everything in it. 或者,您可以创建一个包含所有内容的解决方案。

I ran into the same Issue as you. 我遇到了与您相同的问题。 I do not have a fix - just a workaround which works with msbuild 15 and up. 我没有修复程序-只是一种可与msbuild 15及更高版本一起使用的解决方法。 Same as you I found no way to pass the correct target output path from the clr project to the csproj ProjectReference element or any of its targets. 与您相同,我发现没有办法将正确的目标输出路径从clr项目传递到csproj ProjectReference元素或其任何目标。

Add the following code somewhere in the Directory.Build.targets ( link ) for your solution and the update checks will work. 将以下代码添加到您的解决方案的Directory.Build.targets链接 )中,更新检查将起作用。

All that happens is that the dll will be copied from the OutputPath to the IntermediateOutputPath which allows the FastUpToDateCheck to find it. 所发生的所有事情都是将dll从OutputPath复制到IntermediateOutputPath ,这使FastUpToDateCheck可以找到它。

I have found no issues with doing it this way even though I consider it "hacky". 即使我认为它是“ hacky”,我也没有发现这样做的问题。 It might cause issues if you have very "non standard" build paths / configuration 如果您具有非常“非标准”的构建路径/配置,则可能会导致问题

  <Target Name="CopyClrToProjectOutputForFastUpToDateCheck" AfterTargets="AfterBuild" Condition="'$(CLRSupport)' == 'true' And '$(Language)' == 'C++'">
    <Message Text="Copying CLR Project output to intermeidate output path so that csprojs have the change to do fastuptodatecheck  $(OutputPath)$(TargetFileName) to $(IntermediateOutputPath)$(TargetFileName)"/>
    <Copy SourceFiles=" $(OutputPath)$(TargetFileName)"               DestinationFiles="$(IntermediateOutputPath)$(TargetFileName)" />
  </Target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 图像上的C#Visual Studio 2017隐形+可单击按钮 - C# Visual Studio 2017 invisible + clickable buttons over a image 自定义项目Visual Studio 2017 - Custom project visual studio 2017 通过 Visual Studio 2017 VSIX 项目构建 SQL Server Management Studio 扩展:为 AsyncPackage 类绕过 Initialiaze() - Building a SQL Server Management Studio Extension via Visual Studio 2017 VSIX project: Bypass Initialiaze() for AsyncPackage class 在Visual Studio 2017中建立专案的权限问题 - Permission issues on building projects in Visual Studio 2017 添加在Visual Studio 2017 RC中构建.NET Core项目后运行的msbuild任务 - Add a msbuild task that runs after building a .NET Core project in Visual Studio 2017 RC 在Visual Studio 2017更新到15.8.1 / 15.8.2之后的Xamarin Android App项目构建问题 - Xamarin Android App Project Building Issue after Visual Studio 2017 Update to 15.8.1/15.8.2 使用Visual Studio 2017构建SSDT项目时如何将/ unsafe标志传递给C#编译器 - How to pass the /unsafe flag to the C# compiler when building an SSDT Project with Visual Studio 2017 Visual Studio 未构建项目的依赖项 - Visual Studio not building a dependency of a project 解决方案中的Visual Studio 2017可扩展性项目计数 - Visual Studio 2017 Extensibility Project count in Solution 多项目模板Visual Studio 2017 - Multi project template Visual Studio 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM