Visual Studio Online CI Nunit references not resolved during build - c#

I have been trying to get my solution to build in a CI configuration using Visual Studio Online and the hosted build controller.
I have created a folder in the root of my workspace with the required NUnit binaries as per these guidelines.
I have also referred to these previous questions where users had issues trying to accomplish the same thing:
Visual Studio Online CI Nunit Tests not found during build
What else is needed to get the Hosted Build Controller to run my NUnit tests
I have the "NUnit Test adapter for VS2012 and VS2013" package installed in all of my test projects.
The error messages in my build log are like this:
Tracking_works_when.cs (35): The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type 'TestAttribute' is one of several missing ones, including 'Test', 'TestFixture' and 'TestFixtureAttribute'.
There is also the following warning:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): Could not resolve this reference. Could not locate the assembly "nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The same warning is repeated for "nunit.core.interfaces" and "nunit.core".
Question:
What am I missing? Why are my NUnit binaries not being identified within the hosted build environment and my tests run automatically?

Related

TeamCity C# build failed most likely because of nuget restore issue

I am trying to set up a new TeamCity build job and am facing a build issue.
The build failed because of missing references within ResolveProjectReferences step.
For instance :
JSonTools\JSonHelper.cs(21, 7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
Prior to the build step, 2 restore nuget steps are set up and both ran successfully (one for sdk like project and the second for previous version, in this order)
When I run my solution on the agent and restore nuget packages through VS it is working fine (and TC job will run successfully if made on the same agent)
I noticed the dlls pulled during the restore nuget steps are in the path of my sln, while it seems to be require on others path.
Several VCS are set for this job and from what i can see/understand, the failing projects seem to require the dll to be in their own path under the packages folder.
\this
\is
\my
\path
Project1.csproj
packages\ (<- contains all the Dlls)
\folder1
\Project2.csproj
\Project3.csproj
\packages\ (I have the feeling some Dlls should be here but the folder doesn't exist)
\folder2
\Project4.csproj
\packages\ (same as previously)
Did I missed something ?
Any help would be appreciated.
Thanks,
Cervelle

SSIS package with Script task does not work when deployed programmatically

I am running into the weird issue that the script component of an SSIS package deployed as part of an ISPAC file fails if the project deployment is done in an automated fashion - from C# or using PowerShell, that is. Deploying the exact same project using the Integration Services Deployment Wizzard in Visual Studio does not raise any erros when executing the package on the server.
However, I am getting various errors about things missing in the system namespace when executing the package that has been deployed with C# (using Microsoft.SqlServer.Management.IntegrationServices) such as:
DFT Load STG_ETL_TEST_STAGING_CDC:Error: CS0234 - The type or
namespace name 'ComponentModel' does not exist in the namespace
'System' (are you missing an assembly reference?),
Properties\Resources.Designer.cs, 59, 25
DFT Load STG_ETL_TEST_STAGING_CDC:Error: CS0234 - The type or
namespace name 'CodeDom' does not exist in the namespace 'System' (are
you missing an assembly reference?), Properties\Resources.Designer.cs,
25, 21
I exported the deployed packages and compared their file sizes. I noticed that the ISPAC of the manually deployed project is slightly bigger than the one deployed programmatically. What is the Deployment Wizzard doing to the project that isn't happening during automated deployment?
To exclude that it has something to do with my C# code, I also tried the following PowerShell script from the Microsoft docs. However, it does use the same assembly as I use in my code (Microsoft.SqlServer.Management.IntegrationServices) and the deployed package has the same issues.
I should have mentioned that the project was generated with Biml. Turned out the issue was not related to the binaries but the ISPAC file created by the Biml compiler. Building the project again with VS (using devenv.com theproject.dtproj -build) solved the issue for me and allowed for programmatic deployment of the project.

AppVeyor: Build Failed : Cant locate NUnit assembly

I'm having trouble building these simple tests using NUnit. Project passes the build using MStest, but as soon as I switch to NUnit it fails the build.
The error I'm getting during build process is basically:
Could not resolve this reference. Could not locate the assembly "nunit.framework". Check to make sure the assembly exists on disk. If
this reference is required by your code, you may get compilation
errors.
I have NUnit 3.5 downloaded from NUGET and added the .dll to my references, and still nothing. I also have also made sure the properties of that reference have the copy local property set to true.
Here is my build log URL on AppVeyor (https://ci.appveyor.com/project/ReevMich/traviscitest/build/1.0.26)
This is my appveyor.yml contents if that helps.:
version: 1.0.{build}
branches:
only:
- master
- dev
configuration: Debug
before_build:
- nuget restore
build:
verbosity: minimal
project: FizzBuzz.sln
test:
assemblies:
- '**\*.Test.dll'
artifacts:
- path: '**\*.nupkg'
name: NuGet
Remove packages folder from your repository (it doesn't contain assemblies anyway), so it's always re-created during the build with nuget restore.

Compile ASP.NET MVC2 on Team City Build server

I have an old MVC2 project, which I am trying to move from an old cruise control CI server to our current TeamCity CI Server.
I'm getting screeds of build errors of the form:
Models\State\ControllerStates.cs(3, 18): error CS0234: The type or
namespace name 'Mvc' does not exist in the namespace 'System.Web' (are
you missing an assembly reference?)
I get a lot of warnings of the form:
[14:57:16]ResolveAssemblyReference
[14:57:16]C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,
9): warning MSB3257: The primary reference
"System.Runtime.Serialization" could not be resolved because it has a
higher version "4.0.0.0" than exists in the current target framework.
The version found in the current target framework is "3.0.0.0".
The TeamCity build step is using the Visual Studio (.sln) runner vs2012
Here's part of the csc command logged by team city.
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll et al.
I found a VS2012 installation it works correctly, and the similar parameter looks like this:
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll et. al.
So it's using the wrong version of some assemblies, and I'm not sure why.
I have no idea what was wrong, but I've set up a new build agent and that works correctly, so I don't think TC or my project are to blame, but rather something fishy with the setup on the build agent.
This is not a great answer, but if you have a similar problem you may want to cut to the chase and re-build or add a new build agent.

How to Configure Bamboo to Build NUnit Tests?

I am working on setting a project to use bamboo for CI testing, but have hit a hitch when attempting to compile unit tests. We are using the .NET framework 4.5 and NUnit v2.6.3.13283. When I am in bamboo, I have set up the specific job to check out the source code when a new commit is pushed, and then use MSBuild to build the code. Unfortunately, when it reaches this second step, it decides that it no longer understands what NUnit is.
I have the nunit.framework.dll in the same directory (bin\Debug) as the class .dll, so I'm definitely confused as to how I should go about having MSBuild work out building the NUnit tests.
Any help would be appreciated.
EDIT: Error log for those not faint of heart.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig
/nowarn:1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt
/warn:4 /define:DEBUG;TRACE
/reference:c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
/reference:C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll
/reference:"C:\build-dir\UCL-UNL-JOB1\Unit Class
Library\bin\Debug\Unit Class Library.dll" /debug+ /debug:full
/filealign:512 /optimize-
/out:obj\Debug\UnitClassLibraryNUnitTests.dll /target:library
AngleNUnitTests.cs
"C:\Users\Bamboo\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.cs"
AngleNUnitTests.cs(5,7): error CS0246: The type or namespace name
'NUnit' could not be found (are you missing a using directive or an
assembly reference?)
[C:\build-dir\UCL-UNL-JOB1\UnitClassLibraryNUnitTests\UnitClassLibraryNUnitTests.csproj]
AngleNUnitTests.cs(12,10): error CS0246: The type or namespace name
'Test' could not be found (are you missing a using directive or an
assembly reference?)
[C:\build-dir\UCL-UNL-JOB1\UnitClassLibraryNUnitTests\UnitClassLibraryNUnitTests.csproj]
etc.
You need to use a previous task to MSBuild one (Maybe you could consider to use the VisualStudio Task it works like a charm).
This previous task is a Command Task, it will update the Dlls related to the NuGet Package, in order to achieve it:
Create a New Executable on Bamboo, pointing to the nuget.exe file (if you don't have it you could download from https://www.nuget.org/
Create a New Command Task with the executable your created on the previous step.
On the Argument field: "restore YourSolution.sln"
In my approach I am using a VisualStudio task and after this one a MSTest Runner task.
When using Nuget with a source code repository, you have a couple of options.
1) check in your nuget executable to source code and create a bamboo command task that calls that location relative to the build directory, ${bamboo.build.working.directory}\tools\Nuget.exe.
2) Install the Nuget exe directly on the build server. Then you can create a new executable on Bamboo that you can reference in any task.
To create a new executable for use in tasks, use this - https://confluence.atlassian.com/display/BAMBOO/Defining+a+new+executable+capability
I guess you are using NuGet?
If so, you need to enable NuGet Package restore, because MSBuild does not know how to resolve these NuGet packages. This will create a .nuget directory in your solution which needs to be pushed the repository bamboo uses for the build.
Second problem I encountered when configuring the NUnit test runner with bamboo: the nunit-console.exe uses .NET Framework 3.5 which was not installed on my build server.

Categories