MSTest doesn't find updates in tests - visual-studio-2010

I have a Visual Studio 2010 test solution where I am using MSTest. I will be adding multiple test projects for different components in the future. Recently, when I added a new test project (the first time I've added a test project to the solution since the original test project), I have noticed a strange problem. Whenever I add new tests or modify existing tests in the new project and try to do a "Rebuild Solution", Visual Studio says "Rebuild All Succeeded", but the changes aren't reflected in the Test Results.
I can get the changes to take effect by Rebuilding the specific project, but it's just weird that a Rebuild All doesn't take effect in my added project.
I can tell that the changes aren't taking effect, because I used the above method to build a working test, then added a line to throw an Exception in the test, did a "Rebuild Solution", then watched the test still pass.
This isn't a major issue, but it would be nice to know how to fix it, since I will be doing testing in this pattern for a long time to come.

I felt like a total dunce when I figured this one out.
In the Configuration Manager, I forgot to check the Build box for the added project, so the solution didn't know to build it when I did a rebuild all.

Related

Visual Studio doesn't see code changes at runtime

I recently noticed a strange behavior on Visual Studio (2022, enterprise): whenever I make code changes, I can't see those changes during runtime unless I do a clean + build of the solution.
This started to happen only in the last few days, and I can't understand why (previously, for the specific application on which I'm working on, I just had to do a solution build before running).
It's not the end of the world, but my work is quite slown down having to do a solution clean every time.
P.s. I already tried to delete both the bin and obj folders for every "inner" project inside the solution, but it didn't help.

VS 2012 .user file causes unnecessary builds

There are a number of post in relation to Visual Studio building projects when not necessary. However, none seem to cover this particular issue.
I'm running Visual Studio 2012 Professional Update 4.
In my solution, I have a unit test project that has a project reference to a BizTalk Transforms project. This in-turn has a project reference to a BizTalk schemas project.
Every time I choose to run a unit test, the whole solution is built, even though no changes have been made.
The first line displayed in the build window is as follows:
Input file
'C:\Workspaces\rbowman\Branches\Current-branchRB\WareHouse\FFF.Enterprise.WareHouse.Schemas\FFF.Enterprise.WareHouse.Schemas.btproj.user'
is modified after output file
'C:\Workspaces\rbowman\Branches\Current-branchRB\WareHouse\FFF.Enterprise.WareHouse.Schemas\bin\Release\FFF.Enterprise.WareHouse.Schemas.pdb'.
Note: it seems to be the .user file that's causing the rebuild.
Does anyone know how to prevent this? Strange but I only seem to be getting the problem with BizTalk proj files. I am seeing this behavior across multiple solutions but the problem file is always identified as a btproj.user.
This screencast illustrates the problem: screencast link
You should remove the *.user file from your source control.
These files store user specific settings and should never be checked into source control.
I had the same problem. BizTalk projects insist on updating the btproj.user file on every build, resulting in a full rebuild every time.
I solved the problem with the following workaround: Set the ACL Write Flag on Deny. The build cannot update the file and the projects are only build when actually needed.
In my case build time went from 10 minutes to 2.
If you have just opened the solution, even if nothing has changed since the last time you built, if you click Run All, it will as per the description in Test Explorer do a build.

Visual Studio 2010 F5 Debugging C++ is not Rebuilding

I have a Visual Studio 2010 Ultimate C++ project (not managed or .NET). When I press F5 (i.e., start debugging), I want it to save all the files, rebuild those that changed, link the whole thing, and then run. Instead, it appears to use the last build. Thus, when I try to step into a function or something, I get the following error:
Based on my research, I have verified these options, the first three of which are in the Options dialog (can be reached under "Debug->Options and Settings"):
"Projects and Solutions->Build and Run->Only build startup projects and dependencies on Run" is checked. Some research indicated that it should be unchecked, but in my case I actually do only want it to rebuild the startup project. For what it's worth, I've tried unchecking it, with no effect.
"Projects and Solutions->Build and Run->On Run, when projects are out of date:" is set to "Always build".
"Debugging->Edit and Continue->Enable Edit and Continue" is checked, though it's greyed out.
In the Configuration Manager ("Build->Configuration Manager"), all solution configurations and platforms have their "Build" checkbox checked.
I have also tried deleting all Debug and Release directories as well as the .sdf and ipch directory.
For completeness, I suppose I should mention that I'm using precompiled headers, though I kinda doubt it matters.
[EDIT: I should note that it only seems to be one file (a .h file) that's doing it. I tried renaming it and recompiling, and also removing it from the solution and adding it back in, but it didn't work. ]
I was able to bring my solution back into the right state after deleting all .suo and .csproj.user files. Answer led to this solution. Hope this saves someone time.
I fell into this state after installing Ultimate over Professional and running profiling tools.
Once I had similar problem with my C# project and I think I have tried every possible suggestion available on internet but none worked and then this is what I have done:
Created an empty Project
Added startup function to verify that it does not show any error
Imported all my source code manually one by one
So, Yes, it was the solution. You already have done a lot so I would say you can get lucky by trying here and there however having a new project and importing your individual source file would be faster.
Another solution could be that switching the platform. I noticed that when I when to project properties, the new project I had just created had a platform of 'win32' and my other projects in the same solution had it set at x64. After I switched my project to x64, everything worked just fine. This worked for my interop(C,C+, C#) project and hopefully works for other projects as well.
I have successfully resolved it, try the following:
remove all temporary and intellisense files
remove all project from solution and then add them back(most important)
check projects 'Frameworks and References' to ensure they are valid

what can cause Visual Studio to rebuild my entire solution all the time?

I have a largeish solution in Visual Studio 2008 (around 30 projects, all C# and Script#), including some test projects.
When I start the application or run my tests, way to often Visual Studio rebuilds everything rather than just the changed parts and their dependencies.
If I don't change anything at all, it will not rebuild, but as soon as I change any file in any project, everything in the entire solution will be rebuilt, even the 90% of projects which were not affected at all.
Does anyone have an idea of what the problem can be, or provide me a hint of where I can start troubleshooting it?
Edit: To clarify, all projects in the solution are rebuilt, even those which are not directly or indirectly dependent on the project that has actually been modified. Even those which the modified project depends on, so it can't be a simple project reference issue.
The build sequence is determined by the project references (dependencies).
To avoid to build the projects depending on the project you've edited, you can use Build Current under the menu Build.
I setup CTL+B as shortcut to Build Current which saved me a lot of time than F6. Everytime I just use CTL+B after I save a file.
Hopefully this will help.
You can use the configuration manager to set up a specific config for your sln that will only build the projects you specify. You can find it under Build->Configuration Manager

Build Incrementally in VS 2005

We have a 50 projects solution in VS 2005.
Is any way to get incremental build if nothing was changed?
It is kind of doing it now, but it executes all prebuild and post build events for each project.
Is any way to prevent it?
Have a look at the Build Events tab. Notice the dropdown at the bottom that says Run the post-build event:. Does it say "On successful build"? Try changing it to "When the build updates the project output".
Visual studio does what you describe by default, custom build steps are not executed for up to date projects.
Something in your dependancies or build settings are causing it to update all builds. Unfortunately it's hard to track down without additional infromation.
If you know ahead of time which ones you would like to build or not build, you could create different build configurations that only build specified projects.
This solution doesn't use dependencies at all, so it will only work if you have a few different distinct groups of projects.

Resources