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'.
...
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.