Type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'
The namespace Microsoft.VisualStudio... is defined in assemblies which are not part of the standard Installation of Visual Studio. It is available only if you installed the Visual Studio SDK.
The MSDN Reference to the SDK and included namespaces can be found here.
After installing the SDK add a reference to the required assemblies to your project as described here.
EDIT: Please also check your Visual Studio Version. In the MSDN Link you have posted it says:
You can customize some aspects of Visual Studio Ultimate or Visual Studio Premium to extend existing features or to add new capabilities if you have special requirements. The API reference provides information about the classes to help you with your customization.
If you have one of these Versions, open your unit test project, right click on 'References' -> Choose 'Add Reference' -> Click on 'Assemblies' on the top left and search in the List for 'Microsoft.VisualStudio.TestTools.UnitTesting' (Its either in the 'Framework' or in the 'Extensions' section which you can also choose on the left). You do not need to know the actual location of the dll.
I got this error when trying to build a project in TFS. These steps fixed it:
- remove reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
- add nuget MSTest.TestFramework
- add nuget MSTest.TestAdapter (optional but needed to run tests inside Visual Studio)
The above steps caused this element to be removed from my .csproj file:
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
And these two were added instead:
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
If you're using VS 2017, simply don't put the original project and the test project in the same folder. This will solve the conflict.