I have a .NET solution in Visual Studio 2010 with a bunch of projects. Up until recently, when I would run the startup project from within the IDE, projects would only buil
Just found another reason for rebuilds (at least with the new sdk-style project files, didn't try for the "old style" projects): if the TargetFramework
element in the .csproj file does not match the sku-attribute of the supportedRuntime
-entry in the app.config, visual studio will also rebuild the project every single time.
For example, targeting 4.6.2 in the .csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
</Project>
vs. 4.6.1 specified in app.config
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
will trigger a rebuild.
There can be many reasons for MSBuild to detect a need to rebuild the project.
In my case, I have a bunch of Pre-build events that generate code from XSD files. These causes the project to be rebuilt every time. And then other projects depending on this one will be rebuilt as well.
My Configurations tag in a low level project (i.e. one many others depended on) had 3 entries:
<Configurations>Debug;Release;Debug31</Configurations>
I had been experimenting with a new configuration (Debug31) and forgot about it. Removing the Debug31 configuration from the project file solved the issue. Note that the solution that contained all my projects did NOT have a Debug31 configuration. This appears to have caused this project to always be out of date, even though I was only building 'Debug' or 'Release'. Why I am not sure.
The following worked for me. Go to Properties->Custom_Build_Step, and delete anything in "Description" field.
Go to Tools -> Options -> Project and Solutions -> Build and Run. Look at the options there. 'Only build startup projects and dependencies on Run' should be checked.
Additionally, you can set the build output (in the same options screen) to Detailed or Diagnostic to see if you can find any clues why the projects are built every time.
In my experience with this issue, it was only some of the projects that rebuilt, and the rebuilds failed several times before finally succeeding. It was apparently caused by the \rootprojectdir\.vs\%projectname%\v14\.suo
file being corrupted. This also caused the same projects to require rebuilding, and the same windows to be opened every single time I opened VS. Deleting the .suo file (while VS was closed) and reopening VS fixed it :)