Visual Studio Rebuilds unmodified projects sometimes after a PC reboot

Viewed 747

I've a Visual Studio 2013 solution with about 50 C# projects. Normally if I select build (F6) it just builds the projects which have changed. But sometimes after a I shut down and restart my PC it rebuilds all when I select build (F6). Why?

This doesn't happen all the time when I restart my PC. Most of the times it says that all projects are up to date after a reboot. But sometimes it rebuilds all.

I took a look at the following question Visual Studio Rebuilds unmodified projects and its answers.

The next step I did was to set the build output verbosity to diagnostic.

I'm getting the following output when Visual Studio rebuilds all after a PC restart:

1>Project 'Project1' is not up to date. Missing input file
...

There much more lines (more than 1000). I took a look at them but I still don't understand why Visual Studio rebuilds the project.

Update

Why does Visual Studio needs the following file?

1>Project 'Project1' is not up to date. Missing input file
'c:\users\wo\appdata\local\temp\.netframework,version=v4.5.assemblyattributes.cs'.
...
2 Answers

For future travelers, I think it's also just a bug in current versions of Visual Studio 2019, 16.6 and newer.

This problem happens for me with Visual Studio 2019 versions 16.6.0 and 16.6.1. I have cross-version aware C# projects that do not have this issue for 2010, 2015, 2017, or 2019 16.5 and older, on the same machine and same user, with the same project in the same folder and solution.

With the recent 2019 versions (in the last month or so, May and June 1st 2020) I get similar message:

1>Project 'Banana' is not up to date. Missing input file 'c:\users\banana\appdata\local\temp.netframework,version=v4.7.2.assemblyattributes.cs'.

If I clean then build, then its normal. If I run a successive build I get the error.

This happens with or without reboot, and after cleaning temp folders even, or if I run Visual Studio with admin or not. The path its trying to find really exists, and pops up if paste in explorer.

I've completely cleaned all but the code files with fresh folders and have the same issue. For me it's only with C# projects. So I think it's a 16.6 bug.

See recent changes:

KirillOsenkov commented on Jan 4 2020

@livarcocc would it be possible to prioritize this? This is an impactful issue that's very easy to fix and has been open for three years now. Seems like low-hanging fruit.

bording commented on Feb 12 2020

With the fix for this being merged into master now, which release will it be a part of? I see that this issue is on the 16.5 milestone, so does that mean it will be in that release, or does the fix also need to be ported to another branch?

tmat commented on Feb 12 2020

@bording I updated the milestone to 16.6 as I believe master is 16.6.

https://github.com/microsoft/msbuild/issues/1479

Visual Studio Rebuilds unmodified projects sometimes after a PC reboot

One possibility that caused this issue is that the building account lost permission to the temp folder. To resolve this issue, you can try to grant permissions read/write/execute to the temp folder, or maybe try running visual studio as administrator to see if it is permissions related.

As we know, if we Open/Build a project in visual studio, .NETFramework,Version=v4.x.AssemblyAttributes.cs appears in temp folder automatically. If you lost permission to the temp folder after restart PC or not running visual studio as administrator, we could not access the temp folder, then Visual Studio will report that it can not find the file version=v4.5.assemblyattributes.cs in the temp folder.

Alternatively, you can also generate this file into the Intermediate directory (usually called obj) by adding following property to the project file:

  <PropertyGroup>
    <TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
  </PropertyGroup>

Credentials: MSBuild: unnecessary rebuilds because of generated AssemblyAttributes.cs

Hope this helps.

Related