I've had a variety of .Net Core installations on my laptop. The end result was .Net Core not working in Visual Studio 2015 anymore despite uninstalling and reinstalling .Net Core and associated Visual Studio tools. The problem was probably exacerbated by uninstallers not completing correctly and other sundary issues.
In a perfect world I would have paved the machine and started again but at this point that’s not practical. Working in VMs might also be an option but for now I just want a laptop with .Net Core up-and-runing.
Firstly I decided to find out what was hanging around on the machine. I opened a command prompt and ran dotnet –version to find out.
So this is saying I’ve got version 1.0.0-beta-001598. That seems very old to me and something that should have gone ages ago.
Looking in Add/Remove Programs I see something different.
This suggests 2 other versions have been installed: 1.0.0 Preview2-003131 and 1.0.0 Preview2-003133. Hmm…
So, I had a look at the PATH environment variable on the machine and saw some interesting things. The following directories – that all seem related to .Net Core – were listed in this order:
- c:\Program Files\dotnet\bin
- c:\Program Files\dotnet
- c:\Program Files\Microsoft DNX\Dnvm
Looking in the c:\Program Files\dotnet folder confirmed the installed SDKs but there was something odd. The dotnet.exe appeared in c:\Program Files\dotnet and in c:\Program Files\dotnet\bin. Running them from each location separately revealled different .Net Core versions.
Yep. Things are in a mess.
The c:\Users\username\.dnx\ diectory is also interesting. That isn’t used anymore. What’s in there I wonder?
Turns out it’s got the old – now redundant - dnvm application that gives a different version again. There’s a stack of other stuff in theer too. Sheesh, what a mess I’ve made.
My solution was to do the following:
- Uninstall the .Net Core and VS Tooling using Add/Remove Programs.
- Run dnvm uninstall from the old .dnx folder (probably not necessary but what the heck).
- Manually delete the following directories (and contents):
- c:\Program Files\dotnet
- c:\Program Files\Microsoft DNX
- Remove the same directories as above (and/or sub directories) from both the user and environment $PATH.
- Restart the machine (probably not necessary - belt and braces).
- Installed the latest .Net Core SDK and Visual Studio 2015 Tools from here.
The result? Working .Net Core in Visual Studio!
There was a nice tidy c:\Program Files\dotnet folder with the dotnet.exe and a subfolder containing the SDKs. That’s it, no other folders required or present.