Must I rebuild Nunit 2.6.2 to use it with .net 4.0? - nunit

When I try to run some tests with:
nunit-console.exe <mydll> /framework:net-4.0
I am rewarded with:
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'nunit-console-runner, Version=2.6.2.12296,
Culture=neutral, PublicKeyToke n=96d09a1eb7f44a77' or one of its
dependencies. The system cannot find the file specified. File name:
'nunit-console-runner, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at
NUnit.ConsoleRunner.Class1.Main(String[] args)
There is no file named nunit-console-runner anywhere.
When I leave off the /framework, all is well. However, I need the /framework as my goal is to debug as mixed-mode test failure on a 64-bit system.

Related

Could not load file or assembly System.Linq.Dynamic.Core Version=1.0.15.0

Added System.Linq.Dynamic.Core Version=1.0.15.0 from nuget in current Asp.net core 1.1 project. Added required moethods in library but when method is called error is thrown as "Could not load file or assembly 'System.Linq.Dynamic.Core, Version=1.0.15.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832'. The system cannot find the file specified"
Tried to restore the package but no use

Scripts fail with error that Microsoft.ServiceFabric.Internal.Strings.dll is unavailable when "Microsoft Service Fabric" is installed

After upgrading to the latest tools, runtime and SDK (5.5.216.0), PowerShell scripts, such as TestConfiguration.ps1, fail with an error that Microsoft.ServiceFabric.Internal.Strings.dll version 5.0.0.0 can't be found. As soon as I deinstall 'Microsoft Service Fabric' from the control panel, it works just fine. This behavior seems very similar to the Newtonsoft.Json.dll issue that was resolved in 5.5.216.0, just with a different assembly this time around.
Is this a known issue?
It quickly gets tedious to have to uninstall 'Microsoft Service Fabric' when I run certain scripts and then have to install it again for others that require it.
Example of error:
PS C:\git\sf-admin\DeploymentScripts\Microsoft.Azure.ServiceFabric.WindowsServer> .\TestConfiguration.ps1 ..\ClusterConfig.Production.Shared.json
Trace folder doesn't exist. Creating trace folder: C:\git\sf-admin\DeploymentScripts\Microsoft.Azure.ServiceFabric.WindowsServer\DeploymentTraces
Running Best Practices Analyzer...
Standalone package dependent files not found. Check package structure. Error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or on
e of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.ServiceFabric.Internal.Strings, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Microsoft.ServiceFabric.ClusterManagementCommon.ValidatorExtensions.ThrowValidationExceptionIfNull[T](T parameter, String parameterName)
at Microsoft.ServiceFabric.DeploymentManager.BPA.BestPracticesAnalyzer.IsJsonConfigModelValid(StandAloneInstallerJsonModelBase config)
Thanks,
Hans
I believe you're getting that error due to the SDK/Runtime installing dll's to the GAC which are being picked up.
Try running moving your Microsoft.Azure.ServiceFabric.WindowsServer folder to another machine and running TestConfiguration.ps1 again.
If you're running the scripts from a box without internet access then you'll need to specify the location of the .cab which contains the runtime
-FabricRuntimePackagePath C:\temp\Microsoft.Azure.ServiceFabric.WindowsServer.5.5.216.0\MicrosoftAzureServiceFabric5.5.216.0.cab

Running migrate.exe from powershell for Cloud Services Project?

I'm trying to write a powershell script that runs migrations for a cloud service project:
$migrator = "C:\Path\EntityFramework.6.1.3\tools\migrate.exe"
$migrateCommand = "$migrator file.dll /StartUpDirectory=C:\path\bin\Test /connectionStringName:myconnection /startUpConfigurationFile:C:\path\app.config /verbose"
Invoke-Expression $migrateCommand
And I keep getting the following error when I run the script: "Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."
I have copied migrate.exe to my bin folder where all the dll's are and I'm using absolute path's for the startupdirectory and configuration file. Can't seem to figure out what I'm missing? Also another question I had was could migrate.exe be only used with webrole/workerrole projects?
The problem is migrator was searching entityframework.dll in the same working directory. You could change the working directory to the folder which contains your entityframework.dll

Assembly version conflicts for AutoFixture and Moq with NUnit on TeamCity 7

I previously had all unit tests for my solution contained in a single library, and were recently split out. When located in a single assembly, all tests passed both locally and on TeamCity, but when seperated there are version conflicts.
Config:
Team City 7.1.5 (build 24400)
AutoFixture 3.20.2
AutoFixture.AutoMoq 3.20.2
Moq 4.2.1402.2112
NUnit 2.6.3
I have several unit test assemblies, which all reference a base test library. All test assemblies use the NuGet packages listed above.
When running tests on a dev machine (VS 2015), all tests pass successfully.
When running a team city build, the following error is thrown:
System.IO.FileLoadException : Could not load file or assembly 'Moq, Version=4.1.1308.2120, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(Object request, ISpecimenContext context)
There is no reference to Moq 4.1.1308.2120 anywhere in my solution, so I know it must be a reference from AutoFixture.
Updating AutoFixture to 3.31.3 makes no difference.
I have the following Binding Redirect in the app.config files of all test assemblies:
<dependentAssembly>
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1402.2112" newVersion="4.2.1402.2112" />
</dependentAssembly>
I cannot downgrade my version of Moq to 4.1.1308.2120 as I use features of 4.2 in my tests.
It appears to me that Team City is ignoring the redirects. I have no idea why, and having tried every combination of version for these assemblies I cannot get Team City to run the tests successfully.
We ran into this problem as well. We ran the assembly Fusion Logs on our build server and saw this in the error logs:
Calling assembly : Ploeh.AutoFixture.AutoMoq, Version=3.50.2.0, Culture=neutral, PublicKeyToken=b24654c590009d4f.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Moq, Version=4.1.1308.2120, Culture=neutral, PublicKeyToken=69f491c39445e920
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///D:/builds/13/s/AssessmentMigratorService.IntegrationPostbuild/bin/Debug/Moq.DLL.
LOG: Assembly download was successful. Attempting setup of file: D:\builds\13\s\AssessmentMigratorService.IntegrationPostbuild\bin\Debug\Moq.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Moq, Version=4.5.28.0, Culture=neutral, PublicKeyToken=69f491c39445e920
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated
So if you see this part of it
No application configuration file found.
what I think is happening is that the unit test runner host application on the build server is not seeing the application configuration file and so the assembly binding redirects are not able to apply, since they are in the app.config.
So I see 3 possible solutions/workarounds if you need to use these assemblies:
Figure out why TeamCity's unit test runner on the build server cannot find the application configuration file and fix that.
Use a different unit test runner on the build server.
Add the binding redirects to the machine.config of the build server. That will apply globally on the entire machine, so there is no need for the redirects in the application configuration file at that point.
I was embarrassed when I discovered the reason that I was seeing this error.
After 8 hours debugging I found that I had referenced TestProjectB in TestProjectA. Teamcity was set up to run any xunit against any Test*.dll that it found. So it found the TestProjectB.dll in TestProjectA's /bin/Debug folder.
But there is no TestProjectB.dll.config for TestProjectB.dll when it is in /TestProjectA/bin/Debug. Hence none of the assembly binding/redirect where being set.
I remove the project reference because it was unnecessary and updated my teamcity xunit runner to exclude dlls that don't have a matching config.

"Could not load file or assembly 'TypeMock.Interceptors, Version=0.0.0.0"

We have just upgraded Typemock from 6.0.2.0 to Typemock 7.3.0.0. And we now get the following error at runtime:
[System.IO.FileNotFoundException] = {"Could not load file or assembly 'TypeMock.Interceptors, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0000000000000000' or one of its dependencies. The system cannot find the file specified.":"TypeMock.Interceptors, Version=0.0.0.0, Culture=neutral, Pu...
During debugging I can see that the source throwing it is mscorlib. The mystifying thing is that I have unloaded all of my projects that have references to Typemock.dlls but still get this error. When I choose "suspend mocking" in the Typemock-menu everything works.
In the GAC I can see that Typemock.Interceptors 7.3.0.0 is installed.
Any ideas?
I called TypeMock support, and they confirmed that it was a bug in TypeMock. They sent me a newer version (7.3.2.0) and the issue has now disappeared.