Build and test with TeamCity and Fakes Framework - c#

We are running a TeamCity 8.1.4 buildserver with VS2013 installed on the machine.
I've recently introduced tests which rely on the Microsoft Fakes Framework. Because of this I had to add some references to the new Fake assemblies and the Microsoft.VisualStudio.TestTools.UnitTesting assembly.
This all runs fine on my local development machine.
Now, when I try to build the solution on the TeamCity server, the following errors are thrown:
SomeDirectory\Processors\ProcessorTests.cs(3, 27): error CS0234: The
type or namespace name 'Fakes' does not exist in the namespace
'SomeDirectory.Database' (are you missing an assembly reference?)
SomeDirectory\Processors\ProcessorTests.cs(7, 66): error CS0234: The
type or namespace name 'Fakes' does not exist in the namespace
'SomeDirectory.Service.Processor.Report.Processors' (are you missing
an assembly reference?)
SomeDirectory\Processors\ProcessorTests.cs(9, 17): error CS0234: The
type or namespace name 'QualityTools' does not exist in the namespace
'Microsoft' (are you missing an assembly reference?)
I somewhat understand the first two errors, because I haven't committed the Fake assemblies in SVN, therefore they can't be found. I also don't want to commit these files, because the build server should generate these by itself. The BuildAction of the fakes-files is set to Fakes.
My guess is the first two errors have their origin met at the third error. To my knowledge the QualityTools namespace resides in the Microsoft.VisualStudio.TestTools.UnitTesting assembly.
I've tried to fix this with several settings.
The original build step I had configured was:
Runner type = Visual Studio (sln)
Visual Studio = Microsoft Visual
Studio 2013
I've changed this to:
Runner type = MSBuild
MSBuild version = Microsoft Build Tools 2013
MSBuild ToolsVersion = 12.0
I've also tried the MSBuild version .NET 4.5 with ToolsVersion 4.0.
All of these settings result in the same errors.
As you can understand, the solution won't compile at the moment, so I can't tell for sure if the tests will run or not. I've already found a post on how to configure the test step with TeamCity, but that's the next step.
Anyone got an idea on how to fix these issues with TeamCity and VS2013?
Edit
I've already checked if the TestTools.UnitTesting assembly exists on the filesystem. This assembly is present, so this shouldn't be a problem
Edit 2
Oops, I've misread the third error message. I should have been looking for the Microsoft.QualityTools.Testing.Fakes assembly, because it says it can't resolve the QualityTools namespace. After checking the path Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies I can confirm the dll isn't present on the filesystem.
I've copied it manually to the buildserver and see what will happen next.
Edit 3
After having copied the Microsoft.QualityTools.Testing.Fakes assembly to the build server, the solution compiles like a charm. However, now I'm receiving the familiar
Failed to resolve profiler path from COR_PROFILER_PATH and
COR_PROFILER environment variables.
I've seen this before on a TFS2012 server. This meant it wasn't able to handle shims and we had to upgrade to TFS2013.
I just logged in on the buildserver and saw the VS2013 version is expired. That's perhaps the reason it doesn't work properly. The installed VS2012 installation is version 11.0.50727.1, so Update 3 is not installed. I'll discuss with my colleagues if this can be updated. Hopefully this will resolve the issues I'm facing with the fakes and shims.
Resolved
Apparently someone thought it was funny to install the VS2013 Professional on the buildserver. Therefore the fakes couldn't run, as it's a Premium feature. Installed the Premium version and everything works like a charm now.

Fakes wont run with MSTest you have to you VSTest.Console
Usually (for VS2012 in this case) it is located C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
There is also runner available on http://confluence.jetbrains.com/display/TW/VSTest.Console+Runner, but if this doesnt work, run the executable "by hand", here is reference for running vstest.console.exe http://msdn.microsoft.com/en-us/library/jj155796.aspx.
If you have VS2013 installed on agent machine (Pro edition contains fakes, express doesn't) it should compile fine. Have you tried clean checkout on your dev machine?

Related

How can I resolve "The type or namespace name 'System' could not be found" errors in VS Code?

I'm using Visual Studio Code and .NET Core SDK 3.1.402, and trying to learn how to code C# (so I've got the most recent version of the extension downloaded.
When I create a new project (using cmd, dotnet new console), I am immediately greeted with several errors in the "Hello World" code that it generates automatically.
One of them right at the top is: Unnecessary using directive. [GradeBook]csharp(CS8019)
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [GradeBook]csharp(CS0246)
I'm also noticing problems in the obj\debug{name}.AssemblyInfo.cs.
I've tried:
Reinstalling Visual Studio Code
Repairing .NET download
Restarting Omnisharp
A basic replication here was that the first time I opened Visual Studio code after creating the project in the command prompt was that I was not greeted with errors. I saved and closed after a quick lesson, shut off and on my computer, reopened, and then the errors began showing.
I'm still able to run my code. But the red lines sure do make it hard to learn about the "real" issues.
How do I resolve something like this?
The only thing that worked for me was to completely uninstall my SDK, Visual Studio Code, and C# extension. Then reinstall them all. Once I did that, I was good to go.

Can't access namespaces from Nuget Package

I have an Identity Server 3 Project where I need to install a couple of custom Nuget Packages, that comes from a private Nuget Package repository in my company. This Nuget is installed and running in many other web projects so it is most likely not the problem.
When I install the package on Identity Server Project, logs say everything was fine and the package was successfully installed. It is listed on Project References. But when I try to access it anywhere on Identity Server Project, it just isn't accessible. I can't set up an using reference, neither call any methods by using it's full namespace (InstalledNuget.Services.Example). Visual Studio's intellisense returns "The type or namespace name does not exist in namespace 'company' (are you missing an assembly reference?)".
While investigating the issue, I found out that it is listed on Project References, but not on Object Browser.
I tried:
reinstalling the package;
restarting Visual Studio;
Deleting the packages folder and let the program restore then again;
I have been to several posts here and other websites but did not find a problem matches this one. Any hints?
The error was some visual bug on Visual Studio. I accidentally clicked on run, and it run successfully, with errors still on the screen. It ignored then completely.
Then I manually removed "bin" and "obj" folders and everything returned to normal.

Visual Studio 2017 - Unable to add "ReportViewer" to "Windows Form"

I know this question is exactly the same as this but even after following it's solution i am still stuck up with this error
error CS0234: The type or namespace name 'Reporting' does not exist in
the namespace 'Microsoft' (are you missing an assembly reference?)
Things i did to install Report Viewer
I followed the below link to install the report viewer
Download and Install Report Viewer For Visual Studio 2017 - YouTube
(this link shows how to install it from NuGet Manager and Extensions and update)
and i was able to make a Report as well as add Report Viewer to my Windows Form
but i am getting the above mentioned error on building the program
Solutions i have tried
I tried re-adding the reference by right-clicking on References folder in my project and then selecting Add Reference. and then adding Assemblies > Extensions > Microsoft.ReportViewer to the references.
I tried unloading the project and changing it's .csproj file and manually mention the version
Also cleaned the whole solution and manually removed any other remaining files in the output directory and rebuilding it.
BUT
when i try to see the designer of the form in which ReportViewer has been inserted then the Tooltip says that it is recognizing the namespace
Now, I am left with no solutions now. Any piece of advice will be appreciated.
Maybe you should try to use NuGet Package for install Reporting Service on your Winform application.
I use this NuGet and it's working fine for me.
Microsoft.ReportingServices.ReportViewerControl.Winforms
The answer was to change my .Net Framework from 4.0 Client Framework to 4.0. I guess it needs full features of that framework rather than the client version for it.

TeamCity - Missing 'Microsoft.Web.Infrastructure'

I've been browsing around StackOverflow exploring possible solutions to my issue. For some reason TeamCity is unable to find 'Microsoft.Web.Infrastructure' but I have installed all the required .Net packages. However, I've ran all the tests locally and building the project within Visual Studio returns a successful build.
This is the error which I am experiencing:
App_Start\NinjectWebCommon.cs(9, 40): error CS0234: The type or namespace name 'DynamicModuleHelper' does not exist in the namespace 'Microsoft.Web.Infrastructure' (are you missing an assembly reference?)
Solutions I have tried
Within Visual Studio I was instructed by one StackOverflow thread to set the reference 'Microsoft.Web.Infrastructure' option 'Copy Local' to true. This returned the same result of the error above.
I've deleted all references of 'Microsoft.Web.Infrastructure' and performed a fresh install of this package, I'd had also reinstalled Ninject as well. I didn't specify a particular version. Again, building locally was successful remotely not so much - same error occurred.
Has anyone encountered such issue before? I had also done a fresh clone of the GIT Repository, restored all the NuGet Packages (Which TeamCity does as well) and it built completely fine.
After asking this question I'd continued my investigation. While my continuous integration server is running multiple windows virtual machines, and since TeamCity load balances the builds across these virtual machines some of their configurations were out of sync with the rest. Some of the team code purely in C++, so the version of Microsoft Visual Studio which was installed (Visual Studio Professional 2013) was the incorrect version for my C# project. After attempting to open the project with Visual Studio on one of the selected VM's, I found that Visual Studio didn't understand the csproj file extension.
I installed Visual Studio 2013 Ultimate - this is version I use on my workstation - and thankfully it complied. sometimes within my project, when I request a build it would use older files as TeamCity would cache the files locally. I found setting the to 'clean and re-download' within the VCS options also remedied this issue.

The type or namespace name '"Namespace"' could not be found in the global namespace (are you missing an assembly reference?)

I am trying to build my project by referencing private project using VS2012, it builds successfully on local machine, but I am trying to use Visual Studio Team Services (previously Visual Studio Online, Team Foundation Service) and the build agent set up by Microsoft does not find the namespace.
Tried to re-reference by reading other posts as well checking that target framework is set on all projects to .Net Framework 4, but nothing seems to work, am I missing something ?
Ok, So I solved the issue, the Visual Studio Team Services error log said that the project was not building because the build configuration was wrong and not assigned to building process, it was set to x86 I change it to Any CPU and now it was build successfully, hope this helps to someone.
if your solution have .cs files i.e. class libraries then build that library separately by right click on it and choose option build, then add reference to the website then it will be cleared.

Categories

Resources