VS 2008 keeps removing and re-adding <SubType>ASPXCodeBehind</SubType>

asp.netVisual StudioVisual Studio-2010Visual Studio-2008Visual Studio-2015

asp.net Problem Overview


I've got a VS 2008 C# Web project and whenever I make some changes to the files in it (not even to the project file itself) VS will remove some lines like this from the csproj file:

<SubType>ASPXCodeBehind</SubType>

So something like this:

<Compile Include="Default.aspx.cs">
  <DependentUpon>Default.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>

will become

<Compile Include="Default.aspx.cs">
  <DependentUpon>Default.aspx</DependentUpon>
</Compile>

BUT the next time I work on this project it will add those lines back! It keeps going back and forth like this, resulting in a lot of meaningless "changes" in our source control system. This never used to happen with VS 2005 and it doesn't seem to be happening for other developers who work on the same project file, only for me.

Does anyone know why this is happening and how I can stop it from doing this?

asp.net Solutions


Solution 1 - asp.net

For me, the difference depends on whether or not the web project is open in Visual Studio.

I find if I commit the project file to version control with the project open in Visual Studio the SubType elements are present. Closing the solution/project then removes the SubType elements from the project file. Now I always ensure my commits are performed with the project closed in VS to avoid unnecessary changes to the project file.

Solution 2 - asp.net

Working on VS2010 and solved this issue by deleting solutionFileName.sln.DotSettings.user file and solutionFileName.suo. That helped me, give it a try.

Solution 3 - asp.net

Solution 4 - asp.net

These lines are also appearing in the project file in VS2012 when committing project changes in Tortoise SVN. This project used to be a website that I converted into a web application.

I was able to bypass this issue using the following steps which do not require closing the project:

  1. Just prior to committing to SVN, clean the solution using "BUILD > Clean Solution".
  2. Click the "Save All" button to save the project file.
  3. Commit changes using Tortoise SVN.
  4. Continue working on project...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEMPView Question on Stackoverflow
Solution 1 - asp.netTomView Answer on Stackoverflow
Solution 2 - asp.netAlex DenysenkoView Answer on Stackoverflow
Solution 3 - asp.netEren AygunesView Answer on Stackoverflow
Solution 4 - asp.netlaylareneeView Answer on Stackoverflow