I am using TFS 2008 and VS 2010. After adding a MS Test project to my solution I started receiving following errors on the Build server.
UnitTest1.cs(5,40): error CS0234: The type or namespace name
'UnitTesting' does not exist in the namespace
'Microsoft.VisualStudio.TestTools' (are you missing an assembly
reference?) UnitTest1.cs(22,17): error CS0246: The type or namespace
name 'TestContext' could not be found (are you missing a using
directive or an assembly reference?) UnitTest1.cs(28,16): error
CS0246: The type or namespace name 'TestContext' could not be found
(are you missing a using directive or an assembly reference?)
UnitTest1.cs(62,10): error CS0246: The type or namespace name
'TestMethod' could not be found (are you missing a using directive or
an assembly reference?) UnitTest1.cs(62,10): error CS0246: The type or
namespace name 'TestMethodAttribute' could not be found (are you
missing a using directive or an assembly reference?)
UnitTest1.cs(12,6): error CS0246: The type or namespace name
'TestClass' could not be found (are you missing a using directive or
an assembly reference?) UnitTest1.cs(12,6): error CS0246: The type or
namespace name 'TestClassAttribute' could not be found (are you
missing a using directive or an assembly reference?) Done executing
task "Csc" -- FAILED.
I installed VS 2010 on the build server but still the same errors.
The problem is in your test projects. you're referencing to some assemblies which haven't been deployed to the Build Server. Also you cannot do that by simply copy and paste to GAC or working directory.
The best and easiest way to do that is installing Visual studio 2010 Agents in the build server.
It's free and it can be downloaded from MS web site. By installing the agents, it will install all the required libraries for compiling and even running the MSTest projects.
You could check if you are using correct MSBuild. In my case, when I receive messages such as:
'TestMethod' could not be found
We had to be sure we are running correct MSBuild version.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe your_solution.sln /t:rebuild /t:Rebuild /clp:ErrorsOnly
That also fixes some issues with Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Your tags mention VS2010 and TFS2008. By default unit test projects are set to target .NET 4.0 and Team Build 2008 won't know how to handle those. You should set your test projects to target .NET 3.5 (can only be done if you've installed VS2010 SP1). Or upgrade TFS 2008 to TFS2010.
If you want to run the testing tools with TFS 2008, you should also install Visual Studio Team Developer or Suite on the build agent. Visual Studio 2010 won't help you.
Related
I'm trying to compile a solution that I did not write. I keep getting the CS0234 errors, as well as many other database errors. I also can't seem to add any references since it says all the assemblies are already referenced. The System.Data reference has a yellow triangle. I tried restarting and rebooting several times. I cleaned and rebuilt the project several times to no avail. How do I resolve this issue?
I was able to solve this by copying over a folder full of dll's from my coworker's computer where the project was compiling successfully.
The folder was located at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0
As soon as I copied the folder over and ran a clean & rebuild, the project compiled successfully.
Microsoft Visual Studio Professional 2019
Version 16.0.0
VisualStudio.16.Release/16.0.0+28729.10
I added a .NET Core 2.2 MSTest project and it added dependencies :
Microsoft.NET.Test.Sdk v16.0.1 ( I updated to v16.2.0 )
Microsoft.NET.Test.Sdk v1.3.2 ( I updated to v1.4.0 )
MSTest.TestFramework v1.3.2 ( I updated to v1.4.0 )
I compile and get this error :
CS0234 The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) ...\packages\microsoft.net.test.sdk\16.2.0\build\netcoreapp1.0\Microsoft.NET.Test.Sdk.Program.cs
Microsoft.NET.Test.Sdk.Program.cs
// <auto-generated> This file has been auto generated. </auto-generated>
using System;
[Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode]
class AutoGeneratedProgram {static void Main(string[] args){}}
Couple of observations :
Project is .NET Core 2.2 but it's using package from
netcoreapp1.0 folder
NuGet package manager successfully added package Microsoft.NET.Test.Sdk v16.0.1 but on build it has an unresolved
reference
The type or namespace name 'VisualStudio' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?)
...\packages\microsoft.net.test.sdk\16.2.0\build\netcoreapp1.0\Microsoft.NET.Test.Sdk.Program.cs
If we consume the Microsoft.NET.Test.Sdk package, when we compile and build our project, the Microsoft.NET.Test.Sdk.Program.cs will also be compiled by the csc.exe during the build.
So the error message indicates the Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode attribute can't be recognized well because something is wrong with the reference to Microsoft.TestPlatform.ObjectModel.dll.
Note:
1.Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode comes from assembly Microsoft.TestPlatform.ObjectModel.dll.
2.Microsoft.NET.Test.Sdk package depends on Microsoft.TestPlatform.TestHost package, and Microsoft.TestPlatform.TestHost package depends on Microsoft.TestPlatform.ObjectModel package.
If those packages are installed successfully, the compile and build should work. So actually I think something is wrong in your installed packages.
Some simple suggestions you can try:
1.Go Tools=>Nuget Package Manager=>Package Manager settings to make sure two options of Package Restore are enabled. And then delete the bin, obj folders and run a rebuild.
2.If #1 not works, try clean the nuget cache by UI in VS IDE, and then again delete the bin, obj folders, then run a rebuild.
3.Please update your VS IDE to latest version, 16.0.0 is too old, and latest version has fixed some issues.
Project is .NET Core 2.2 but it's using package from netcoreapp1.0
folder
If you open the package in path ...\packages\microsoft.net.test.sdk\16.2.0\build you can find this package only have three version of assemblies, net40, netcoreapp1.0 and uap10.0. Since your project is .net core 2.2, it will reference the assembly in netcoreapp1.0 folder. It's expected behavior.
I have some solution created in Visual Studio 2015, with usages of NuGet packages.
When I compile the solution from Visual Studio (both of settings "Allow to download missing packages"
and "Automatically check for missing packages during build" are set ON) - it works.
But when compiling the solution on TeamCity (which calls MSBuild for build) - it fails:
Error : the type or namespace name 'someName' cannot be found (are you missing using directive or assembly reference?), where 'someName' defined in the assembly to be installed by NuGet
In TeamCity there are two separate steps defined:
NuGet install - it was verified that packages installed on build agent
Build itself
Is there a parameter of MSBuild to be checked?
What can be the cause of the issue?
Error : the type or namespace name 'someName' cannot be found (are you missing using directive or assembly reference?) , where 'someName' defined in the assembly to be installed by Nuget
According to the error log, you need add a step to your build process to restore all NuGet packages. You can refer to the document NuGet Package Restore with TeamCity for more detail.
I'm running a msbuild batch command in order to build my solution and i'm getting: error CS0246: The type or namespace name '******' could not be found (are you missing a using directive or an assembly reference?)
This is the batch command:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe %~dp0****.sln /t:clean /t:reBuild /v:d /m:4 /p:Configuration=Debug /p:Platform="x86"
But when i'm running a build for the same solution from within the visual studio everything works fine.
I checked project dependencies and everything looks fine, the same problem happens when i'm running TFS build with the build definition I had built for this solution.
I'm building with Visual Studio 2013.
Any idea?
Apparently by removing the parameter /p:Platform="x86" the problem was solved, I have no idea why it crashed the build, might be because the solution configuration was already on x86.. could be a bug in MSBuild?
I tried to install MvcMailer and as soon as I added the package my project it died. I started getting all kinds of error messages concerning dependency conflicts with different versions of T4Scaffolding..versions 1.0.7 and 1.0.8. So I uninstalled the MvcMailer.
When I run the program I still get the same message: A different version of T4Scaffolding is already running in this instance of Visual Studio
Please restart Visual Studio to avoid unexpected behavior.
You won't be able to use scaffolding until you restart Visual Studio.
And my models have error message like:
The type or namespace name 'ColumnAttribute' could not be found (are you missing a using directive or an assembly reference?)
Or
The type or namespace name DatabaseGenerated could not be found (are you missing a using directive or an assembly reference?)
I am using EntityFramework 4.50501 SP1Re l.
MvcMailer seems like a great idea but since I installed it I can't run my program anymore. Is there anyway that I can simply get back to having my program revert back to the settings before I installed MvcMailer?
In the root of your project there'll be a Packages folder. Deleting T4Scaffolding version 1.0.7 should resolve the conflict.