1
votes

I had a few minutes this morning to try to figure out why Visual Studio 2017 rebuild all of my projects in the solution every time I try to run the project. I think I know why this is happening but I'm not sure how to fix it.

I saw these articles:

http://michaelscodingspot.com/2017/04/28/visual-studio-keeps-rebuilding-projects-no-good-reason/

https://ofekshilon.com/2015/08/16/visual-studio-projects-that-just-keep-rebuilding-or-how-quantum-mechanics-mess-up-your-build/

Which got me to turn up build logging.

I now see that VS is looking for PDB files in the OBJ directory and since they are not there(1), VS thinks the project needs to be rebuilt.

3>Project '****.Common' is not up to date. Missing output file 'C:\*******\***\****.Common\obj\Debug\***.****.Common.pdb'.2>Build started.

1) The PDB files are not in the OBJ directory for the assembly projects. They are in the BIN directory. Note that in the main "executable" web project the PDB files are in both the OBJ and BIN directories.

So now I need to make visual studio do one of the following:

  • Put a copy of the PDB in the OBJ directory for all projects
  • Make VS check in the BIN directory for the PDB

I did some search but haven't been able to figure out a good set of search terms to find the answer to this one.

Note this is a project that has been developed using VS2012, VS2015, VS2017 and maybe some before 2012, so this might be part of the problem.

1
No, in any vanilla project the pdb is built into the obj directory. After which it is copied into the bin directory. Same story for the dll. Why this Common project does not do this is something you'll have to figure out from the build trace, you did not show anything relevant that helps us help you.Hans Passant
Yeah, I was thinking it should work that way, so maybe something is deleting it during the build. I'll take a deeper look to see if I can figure out if it is getting deleted. because it is ending up in the BIN folderTechSavvySam

1 Answers

0
votes

This was an issue with assembly project that had been created in older versions of Visual Studio (the projects created in VS2017 don't have the problem).

The workaround I found was to change this part of the .csproj file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
 ...
<OutputPath>bin\Debug\</OutputPath>
 ...
</PropertyGroup>

to:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
 ...
<OutputPath>obj\Debug\</OutputPath>
 ...
</PropertyGroup>

Note that you can make this change in "Properties / Build" under "Output" by editing "Output path". Also note that this is apparently a workaround because I didn't need to do this to the VS2017 projects. If I go and exhaustively try to figure out the differences between the proj files, I'll update this answer.

There were a few other content items set to "Copy Always" which also forces the whole project to rebuild. I changed those to "Copy if Newer".