question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project always rebuilt: Improper up-to-date check with conditional items

See original GitHub issue

This issue has a corresponding ticket on Developer Community. Please vote and comment there to make sure your voice is heard.


  1. Create a new project (I used C# UWP app, this bug may be in other project types).
  2. Add a content file (for example, dummy.xml)
  3. Change the file to “Copy if newer”
  4. Save the solution
  5. Open the project file in a text editor (e.g. by unloading the project and selecting Edit from the context menu)
  6. Find the content file and add a condition that always fails. For example, change this:
    <Content Include="dummy.xml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>

to this:

    <Content Include="dummy.xml" Condition="'Foo' == 'Bar'">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  1. Reload the project
  2. Build
  3. Build again

(The attached project contains this repro).

Expected: In step 9, the project should not be rebuilt since everything is up to date.

Actual: The project is rebuilt. In the output window we see the following trace:

1>Project ‘VSBug7’ is not up to date. Copy to output file ‘c:\prj\VSBug7\bin\x86\Debug\dummy.xml’ missing from output location. This is incorrect, since dummy.xml was excluded due to the condition.

Additional notes: Although the repro steps in this bug use a condition that always fails, this is only for illustration purposes. I found this bug with a more sane condition (Condition="'$(Platform)' == 'x64'") which is sometimes true and sometimes false. The point is that when the condition is false the dependency is not properly ignored in the up-to-date check.


Original Comments

Oz Solomon [MSFT] on 3/12/2020, 07:34 AM:

I'll also add that this problem occurs if the condition is placed on the `ItemGroup` rather than the item.

Visual Studio Feedback System on 3/12/2020, 07:14 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Sara Liu [MSFT] on 3/17/2020, 01:03 AM:

Thank you for your feedback and taking the time to reach out to us. I can reproduced this issue through your shared steps and this issue has been escalated for further investigation, if there is any process, I will inform you immediately.

Maik Gerth on 6/18/2020, 03:36 AM:

I have the same problem when we copy .dlls conditionally based on the Platform in C#, example from .csproj:

<Content Include="…\DLL\testx32dbg.dll" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Link>testx32dbg.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="…\DLL\testx64.dll" Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<Link>testx64.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>


Then Visual Studio Diagnostic Build will always trigger a rebuild, because it thinks that one of the .dlls (from the irrelvant Platform for the current build which it therefore did not copy) is missing e.g. in 32bit Debug it would show

Project 'MyProject' is not up to date. Copy to output file '…Debug32\textx64.dll' missing from output location.


Original Solutions

(no solutions)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mgexocommented, Dec 15, 2020

@mgexo there are two main C# project systems that ship with VS.

  1. The “new project system”, which handles SDK-style projects and which receives the greatest amount of development.
  2. The “legacy project system”, which handles traditional .csproj files, which is stable but lacks modern features.

So to answer your question, the new project system was available back in July when this issue was closed.

For all readers who wonder what this is about, see https://github.com/dotnet/project-system/blob/master/docs/opening-with-new-project-system.md

0reactions
drewnoakescommented, Dec 15, 2020

@mgexo there are two main C# project systems that ship with VS.

  1. The “new project system”, which handles SDK-style projects and which receives the greatest amount of development.
  2. The “legacy project system”, which handles traditional .csproj files, which is stable but lacks modern features.

So to answer your question, the new project system was available back in July when this issue was closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues with incorrect up-to-date checking
With our solutions, we regularly face problems where many projects decide that their respective outputs are not up-to-date and rerun all ...
Read more >
Visual Studio Rebuilds unmodified projects
Project 'ReferencedProject' is not up to date. Project item 'c:\some.xml' has 'Copy to Output Directory' attribute set to 'Copy always'.
Read more >
Visual Studio Projects that Just Keep Rebuilding, or
But occasionally some projects are rebuilt despite not being modified. If by bad luck these projects are high up the dependency tree –...
Read more >
Rider does not rebuild the project after code change - YouTrack
My usual process is to make the code change then just hit rerun or debug again to restart the project, but I noticed...
Read more >
Build solution | ReSharper Documentation
To build, rebuild or clean a specific project, right-click it in the ... ReSharper Build already knows if the timestamps are up to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found