AppVeyor: Build Failed : Cant locate NUnit assembly - c#

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.

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

Net core VS test task is failing with the error : assembly specified in the application dependencies manifest deps json was not found

Currently, we are using .Net Core 2.1 Framework for our test automation Web API Project.
I am trying to run one of the test project dlls for test cases execution.
Please find below the command through Visual Studio IDE
Command : dotnet test APItests.dll,
The above command works well on my local machine with Visual Studio, test cases are getting executed.
I have built the Azure Build pipeline as well as the release pipeline for the same.
Also artifacts are getting published to drop location.
But in the release pipeline .Net core test task is failing with the below error.
Framework: .Net Core 2.1
Error:
An assembly specified in the application dependencies manifest (APItests.deps.json) was not found:
package: ‘Microsoft.AspNet.WebApi.Client’, version: ‘5.2.6’
path: ‘lib/netstandard2.0/System.Net.Http.Formatting.dll’
Could you please find the YAML file details below.
Steps:
task: DotNetCoreCLI#2
displayName ‘dotnet custom’
inputs:
command: custom
projects: ‘\TestAutomation.Application.Hosting.WebApi\ApiTests.dll’
custom: vstest
workingDirectory: ‘$(System.DefaultWorkingDirectory)’
Could you please have a look once and let me know the suggested solution for the same.
To resolve this An assembly specified in the application dependencies manifest (APItests.deps.json) was not found: package: ‘Microsoft.AspNet.WebApi.Client’, version: ‘5.2.6’ path: ‘lib/netstandard2.0/System.Net.Http.Formatting.dll’ error, try either of the following ways:
(Thank you Jirapong. Posting your suggestion as an answer to help other community members.)
You can try upgrading all project dependencies or modifying the installer to include the new files.
If the migration is a class library in Azure Functions project then you have to make sure when you run Add-Migration while the EF Library project is selected as Startup Project.
You can refer to An assembly specified in the application dependencies manifest (appname.deps.json) was not found: package, An assembly specified in the application dependencies manifest (...) was not found and Fixing “An assembly specified in the application dependencies manifest projectname.deps.json was not found”

The type initializer for ‘LibGit2Sharp.Core.NativeMethods’ threw an exception

Specific Exception received: “Could not load file or assembly ‘System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, Culture=neutral’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.”
I have two projects, one is a sort of “Proof of concept” and the exact same code works perfectly there, while the other is a large solution in which I’m adding code to one of the existing projects.
I am getting an exception in the second (failing) project when running the following line of code:
LibGit2Sharp.Repository.Clone(baseGitHubURL + ourOrg + “/“ + ourRepo.Name, ourRepoPath + #“\” + ourRepo.Name, co);
Ahead of this code, I’ve got it printing the arguments being passed, which are as follows in the output from BOTH projects (again - identical code in each):
GitHub path: https://github.company.com/TESTING/CA4F
Filesystem path: C:\Users\User\CA4F
The creation of CloneOptions is identical in both projects with static values being used (it uses a personal access token as a username).
I am suspecting there is something wrong with how LibGit2Sharp was added to the failing project. Note that the PROCESS was the same for both:
From NuGet console: “Install-Package LibGit2Sharp”
Both have the same version (latest, version 0.25.0).
Despite these facts, the working project has a “Dependencies” section under the project listing LibGit2Sharp, while the non functioning project does not have this section. LibGit2Sharp WAS added as a reference to my actual project when I went to Nuget Package Manager and told it to install to ALL projects in the solution.
Another piece of information - the working project does NOT have a NuGet package for “LibGit2Sharp.NativeBinaries”, while the failing project does. On a whim, I tried deleting it from the failing project, but Nuget says “Unable to uninstall ‘LibGit2Sharp.NativeBinaries.1.0.210’ because ‘LibGit2Sharp.0.25.0’ depends on it.”
Just to close this up - I was able to resolve this by adding the following to the first configuration property group under the PropertyGroup tag in the csproj of every single project in the solution:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
After doing that, a recompile and run allowed me to successfully call LibGit2Sharp! :)
Note that this was the solution provided by “bording” over on the LibGit2Sharp git issues “forum”.

xUnit skips tests with "could not find dependent assembly" warning

After updating an assembly, my xUnit tests fail to run.
My project was using System.Web.Http version 5.2.3. I replaced this using Nuget with a fork of System.Web.Http version 5.2.4. Inspecting the reference shows the correct path to the new DLL.
When I run xUnit, it discovers the tests, but gives me the following warning:
[11/04/2018 10:43:30 AM Warning] [xUnit.net 00:00:00.9421698] Skipping: API.IntegrationTests (could not find dependent assembly 'System.Web.Http, Version=5.2.4')
It then skips all tests.
I'm at a loss. Any help is very appreciated.

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