Edits were made which cannot be compiled. When using Resharper in VS2019 - visual-studio

I have a multi project solution using .Net Core 2.1
With VS2019 16.3.9 and Resharper 2019.23 Build 192.0.20191016.60459
If I try to run a test in debug, it will run ok once.
On the second run I will get the error
Edits were made which cannot be compiled. Execution cannot continue
until the compile errors are fixed.
I have tried deleting the .vs folder
A similar question is asked here but I thought it was worth starting a new question as this is related to Resharper.
I get the error in the VS unit test window and in Resharper's test window.

Potentially this is caused by Visual Studio's Edit & Continue feature.
A workaround is to disable this feature:
Debug --> Options --> Debugging --> General --> uncheck Enable Edit and Continue
Solution taken from here.

Make sure than your debugging things are like this:

Related

How to figure out why ReSharper is not rebuilding unit test project before running?

Recently I am having an annoying problem. When I go to Unit Test Sessions window and run some tests, ReSharper seems to completely ignore any changes in my code(even in the code of the test itself!) and does not rebuild anything. Because of that I have to rebuild everything manually. I think that problem is too generic to post on bug-tracker so I would like to find at least any additional information. For MsBuild I can always enable diagnostic logging and track all its decisions during build. How can I find what is the problem with ReSharper?
Versions:
Visual Studio 2015 Pro Update 2; ReSharper Ultimate 2016.1.2.
Have you installed the Rider EAP by any chance? There is a bug in the latest EAP (EAP7) that sets the build action before running tests to "Never", and since the global settings file is shared between Rider and ReSharper, this also causes ReSharper to not build tests before running. The fix is simple - just change the value in the drop down in the unit test runner window. See the bug report for more details.
One thing I'm not sure on is if this is a recurring issue - i.e. the value gets reset to "Never" every time Rider opens the unit testing window. This is an unfortunate bug, and will definitely be fixed for EAP8.

VS 2015 Update 2 - Variable does not exist when debugging, why?

I'm using VS 2015 Update 2 with an asp.net 5 web project configured for debug mode. When I run the project with F5 to debug it and hit a break point, some variables can not be observed in the watch window even when they are in scope. Further, if I hover over such variables no value is displayed.
If I use the same visual studio to create an empty web project and add a webform and place the code in the load method, the debugger works fine. That is to say, I can see the variables in the watch window and I can see their values by hovering over them. I glean from this that the root cause of the issue is not VS2015 Update 2 but rather something to do with the project or solution configuration, perhaps specific to asp.net 5 web projects.
I've scoured the web for answers and similar problems happen when trying to debug compiler optimized code. But I am running the solution in debug mode. Any suggestions?
I am aware of Variable does not exist in the current context while debugging but it applies to a different version of visual studio and the solutions offered there do not fix my issue.
I had the same problem. Eventually I noticed that some settings are different after update 2.
You need to go to Tools --> Options --> Debugging --> General and then check "Use Managed Compatibility Mode".
That worked for me.
This is a bug that was introduced in Visual Studio 2015 Update 2. Essentially the debugger is unable to inspect local variables in dynamic modules. We released a hotfix for it today. You can download the patch here. Documentation for the patch is here. Let me know if the patch does not fix your particular scenario.
Thanks!
-Patrick Nelson

Visual Studio builds every time

I'm running VS2010, debugging as normal, and suddenly I notice that my code changes are having no effect. Moreover, even when I just type in some random crap and hit 'play', it still builds regardless. How do I fix this?
Thanks!
I would check your Settings in the Tools --> Options --> Projects and Solutions --> Build and Run Section making sure Save all changes is selected and Launch Old Version is not Selected.

How to make ReSharper re-evaluate its assembly reference highlighting

I am creating a Prism Project Template, and the template works great. But after I create a project with the template some of the files look like this:
Despite appearances, everything is just fine.
If I do a Rebuild All I see that the solution builds with no errors:
But the rebuild all does not get rid of the "errors" that are showing in the editor window. (Note that the actual error window does not show any errors.)
I can clean, rebuild, close and open files, and it will not fix the highlighting.
However, if I close the solution and re-open it, all is well:
My Question:
Ideally there would be a way for my template or my IWizard to tell ReSharper to reload the references for the highlighting.
I know I can turn ReSharper off and then on again and that will fix it, but I would rather not do that.
Is there a ReSharper command that just refreshes this stuff?
Except for reinstalling, the only way to successfully clear the caches is to delete the files manually from your AppData directory.
Delete the solution folder that's giving you grief in the following locations:
%LOCALAPPDATA%\JetBrains\ReSharper\v7.1\SolutionCaches\
%LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVsXX\vXX\SolutionCaches\ for newer versions.
Note that the version numbers in the paths may be different depending on the ReSharper version that is installed.
The XX in vXX and VsXX represents any number, because there might be multiple folders where the solution cache is stored.
Try unloading and then reloading the project.
To unload the project, right-click the project in the solution explorer, and select Unload Project. Then, right-click the project again and select Reload Project.
The issue continues to occur occasionally with the latest versions of ReSharper, but the fix seems to work for every version.
You could try clearing the ReSharper cache via menu ReSharper → Options → Environment/General → button Clear Caches.
This worked for me. There is no need to reload projects. You can do this from within Visual Studio.
Clear the ReSharper cache via ReSharper, Options, General, click 'Clear Caches'.
ReSharper, Windows, select 'Solution Errors'. This will launch the Solution Errors window. At the top of this window, click the button to 'Reanalyze Files With Errors/Warnings'.
Open ReSharper - Options - Environment - General, scroll down to Msbuild access and select Obtain data from msbuild after each compilation.
This worked for me, using ReSharper 10.0.1 with ReSharper Build.
Go to ReSharper → Windows → Solution Errors Window, and you will get an overview of the errors in your solution. There, you can click the button Reanalyze Files With Errors.
If you want, you can assign a shortcut to this. Go to Tools → Options → Keyboard, and search for "Reanalyze". You can assign a keyboard shortcut to either 'ReSharper_ErrorsView_ReanalyzeAllFiles' or 'ReSharper_ErrorsView_ReanalyzeFilesWithErrors'.
I have a similar issue with nuget packages and I found a most weird workaround: select the reference in project reference list and press 'F4'. Somehow properties window appearance causes resharper to reevaluate available references...
I am not certain this is the same root cause, but I discovered that, within the ReSharper options, "Use MsBuild" was checked and I got all sorts of erroneous errors reported. Try checking "ReSharper->Options->General" and see what state the "Use MsBuild" check is in.
Go to ReSharper → Options → General and click Clear Caches. (I have 8.2, so if you're on a different version it may be elsewhere.)
You'll then need to re-open your solution, and ReSharper will re-analyse everything.
Run the following code in a command prompt. Then solve the ReSharper issue...
del /q/f/s %TEMP%\*
The only thing that helped me is: Unistall and than Install Resharper again (Repair didn't work)
Visual Studio 2010 SP1, ReSharper 7.1.3000.2254
This is a strange issue, and is still alive and well in version 8.2.3 (build 8.2.3000.5176).
What seems to work for me on a consistent basis is to do a solution rebuild.
In VS 2013: Build -> Rebuild Solution
If the solutions above don't work you can try resetting the project output type. This seems to fix the issue on VS2015 Update 1 with ReSharper 10.1
For me none of the above worked. I had to install the new version of Resharper which supports NET Core 2.0.
Resharper was reporting a missing reference from a project that was included in the references. After trying the other solutions here, I disabled Resharper via the instructions this answer, and I found that Visual Studio's intellisense still reported the same errors.
At this point, I realized there was probably something wrong with the project file. I suspected a reference had gotten subtly corrupted during a merge.1
I deleted the reference it was complaining it couldn't find and re-added it. The errors from Visual Studio went away. Then I re-enabled Resharper, and it was no longer complaining about errors in my project.
When I checked to see what had changed in the csproj file, what I found was an extra </Compile> that had no corresponding open tag. So it was indeed a merge error.

Is there a free Visual Studio addin for Nunit?

I'm cheap and don't want to pay for ReSharper or TestDriven.NET, is there a free visual Studio addin for NUnit?
You can create a blank project (Choose console application for example) and in the property of the project you can select DEBUG tag and select "Start External Program". Put the path of Nunit. Then, in the start option, the command line arguments select the DLL that contains all your tests (mine is always in the nunit\bin...). Then select "enable unmanaged code debugging" and you will be able to start the project inside VS and even use the debugger step-by-step.
This is a free solution.
Now you can use Gallio: it's open source. www.gallio.org
By the way TestDriven can be downloaded for free if it's for personal use or Open Source project.
I had to find a way to use .Net Reflector inside VS few days ago and when I downloaded TestDriven it cames with. Never got any popup asking me to paid.
NUnit actually ships with a basic integrated runner. It's not very good, and not very publicized, but unless Charlie has taken it out, it should be in the source.
I know this is an old question but another way to do this is to add an external tool from the tools menu to run nunit - set the arguments to be $(TargetName)$(TargetExt) and initial directory to $(ProjectDir)\bin\Debug
check out this link
This is an old question and things have changed since the answer was accepted.
You may try NCrunch to run tests automatically or manually.
If you're running Visual Studio 2012, there is a plugin written by Charlie Poole, one of the NUnit contributers, that makes use of the new Visual Studio Unit testing plugins.
Download VsTestAdapater - it's also in the extension manager.
Unfortunately it doesn't have much grouping options yet, either by run/not run - so you can't group by class, solution and so on. It also doesn't show you any stacktrace if a test fails, just a simple green tick or red box and a message.
I haven't used it, but NUnitit is a free Visual Studio Add-in for NUnit.
http://nunitit.codeplex.com
From my experience, the best add-in for visual studio is resharper. TestDriven.Net is also good for unit tests. Hope that helps
Also found this one : http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
It is able to launch your tests in debugger, however you need to recompile the code manually each time you change something - no auto run-build integration

Resources