I have created a Service Fabric application and added an MSTest project in the solution to test methods in the services.
For that, I have added a service project reference to HelloWorldAPI.dll in the MSTest project.
After this, I created an automated build definition in Visual Studio Team Services (was VSO), and I'm trying to execute Visual Studio Test cases through this build. However, I am getting the below error:
> Starting task: Test Assemblies **\*test*.dll;-:**\obj\**
******************************************************************************
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.104.1\tasks\VSTest\1.0.50\VSTest.ps1
Working folder: C:\a\1
Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\a\1\s\POC\ServiceFabric\HelloWorld\UnitTestProject1\bin\Debug\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll" "C:\a\1\s\POC\ServiceFabric\HelloWorld\UnitTestProject1\bin\Debug\UnitTestProject1.dll" /logger:trx
Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Failed GetHelloWorldString
Error Message:
Unable to create instance of class HelloWorld.Test.ProductContollerTest. Error: System.BadImageFormatException: Could not load file or assembly 'HelloWorldAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format..
Stack Trace:
at HelloWorld.Test.ProductContollerTest..ctor()
- ***Error Message:***
*
**
> Unable to create instance of class
> HelloWorld.Test.ProductContollerTest. Error:
> System.BadImageFormatException: Could not load file or assembly
> 'HelloWorldAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
> or one of its dependencies. An attempt was made to load a program with
> an incorrect format..
**
*
Please find the attached below configuration details in Team Services:
VSTest Configuration Details
Stack Trace:
at HelloWorld.Test.ProductContollerTest..ctor()
Failed GetAllProductListTest
Test Run Failed.
Results File: C:\a\1\TestResults\buildguest_TASKAGENT5-0026 2016-08-22 08_48_07.trx
Total tests: 2. Passed: 0. Failed: 2. Skipped: 0.
Test execution time: 0.4165 Seconds
System.Exception: VSTest Test Run failed with exit code: 1
Publishing Test Results...
Test results remaining: 2
Published Test Run : https://jci.visualstudio.com/Project%20-%20Microservices/_TestManagement/Runs#runId=3191&_a=runCharts
Is it possible to load dependent (project) assembly in the VSTest execution step?
I am too late to answer this. But today I was facing the same issue and so I thought to share my solution here. It may help someone.
Note - I am using Visual Studio 2017.
For me it was happening because of inconsistent processor architectures (32 bit / 64 bit) used across assemblies/projects.
To fix this, I set the architectures of all projects to 64 bit (x64). You can do this by right clicking your solution in Solution Explorer, then Properties > Configuration Properties and click on the Configuration Manager button.
Next I set the Default Processor Architecture of tests to x64 . You can do this by clicking on the Test menu > Test Settings > Default Processor Architecture > x64.
Make sure you are executing the library produced at the correct path - \bin\x64\Release\mytests.dll
Related
Recently added Visual Studio 2022 to M1 Macbook, so I tried to add new console app and NUnit class library project in this sample project
This TDDSample.UnitTest project's target framework is ".NET 6.0.6".
Everything is building successfully, but when I try to run this unit test project, it's showing the following error:
Testhost process exited with error:
Error: an assembly specified in the application dependencies manifest (TDDSample.UnitTest.deps.json) was not found:
package: 'NUnit', version: '3.13.3'
path: 'lib/netstandard2.0/nunit.framework.dll'
Please check the diagnostic logs for more information.
Testhost process exited with error:
Error: An assembly specified in the application dependencies manifest (TDDSample.UnitTest.deps.json) was not found:
package: 'NUnit', version: '3.13.3'
path: 'lib/netstandard2.0/nunit.framework.dll'.
Please check the diagnostic logs for more information.
After deleting the unit test project and recreating the unit test project, issue able to fix, seems like some project cache problem
I've just updated my VS to ver. 16.8.3 and now suddenly I am getting this error:
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1720,5): error :
Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build
Not sure at all what to do about this.
We have been working on this project for years and never had such an issue.
Any thoughts?
Seems that the problem is with projects that use multiple .net frameworks AND they referenence ANOTHER project that uses multiple .net frameworks
I have a MINIMAL sample solution at: my public drive
The solution contains two minimal/empty projects that are technically the same except that the one named Microdesk.DbApp referencing the one name Microdesk.Infrastructure.
The Infrastructure project compiles fine while the DbApp project throws the above error.
This solution was working fine for us for multiple years and broke with the latest VS release 16.8.3
Okay, partially my bad.
I did re-compile the EMPTY sample project and found that despite the compiler error, the solution does build.
1>------ Rebuild All started: Project: Microdesk.BIMrxCommon.Infrastructure, Configuration: Debug2020 Any CPU ------
1> Microdesk.BIMrxCommon.Infrastructure -> C:\Work\Microdesk.BIMrx\bin\Debug2020\Microdesk.BIMrxCommon.Infrastructure.dll
2>------ Rebuild All started: Project: Microdesk.BIMrxCommon.DbApp, Configuration: Debug2020 Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1720,5): error : Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build
2> Microdesk.BIMrxCommon.DbApp -> C:\Work\Microdesk.BIMrx\bin\Debug2020\Microdesk.BIMrxCommon.DbApp.dll
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========
BUT if you try to USE anything from the Infrastructure project in the referencing DbApp project then the Solution will NOT compile
Rebuild started...
1>------ Rebuild All started: Project: Microdesk.BIMrxCommon.Infrastructure, Configuration: Debug2020 Any CPU ------
2>------ Rebuild All started: Project: Microdesk.BIMrxCommon.DbApp, Configuration: Debug2020 Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1720,5): error : Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build
2>C:\Work\Microdesk.BIMrx\BIMrxCommon\Microdesk.BIMrxCommon.DbApp\DerivedClass.cs(1,29,1,4
): error CS0234: The type or namespace name 'Infrastructure' does not exist in the namespace 'Microdesk.BIMrxCommon' (are you missing an assembly reference?)
2>C:\Work\Microdesk.BIMrx\BIMrxCommon\Microdesk.BIMrxCommon.DbApp\DerivedClass.cs(5,33,5,42): error CS0246: The type or namespace name 'BaseClass' could not be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
I did upload a second sample project named "Microdesk.BIMrx (2).zip" to the previous OneDrive directory
When I test your issue in your side, I did not face the same behaviors as you described. So I guess that there is some issues on your current vs environment due to the update. And maybe the update broke some tools of VS.
So please try the following steps to troubleshoot it:
Suggestions
1) disable any third party installed extensions under Extensions-->Manage Extensions-->Installed
2) close VS, delete .vs hidden folder, every bin and obj folder of your project.
and also delete all cache files under C:\Users\xxx(current user)\AppData\Local\Microsoft\VisualStudio\16.0_xxx\ComponentModelCache
Then, restart VS to test again.
3) or create a new project and then migrate the content from the old into the new one to test whether the issue is related to your VS or the special project itself.
4) If this does not work, do an initialization operation on your VS.
Close VS, delete the whole user folder under C:\Users\xxx(current user)\AppData\Local\Microsoft\VisualStudio\16.0_xxx and then restart VS to test again.
5) repair vs from the vs_installer
I have an "old" XAML Build Definition, made in Visual Studio; which builds a solution and following runs unit tests.
Now I've tried to make the same in the new TFS 2015 web surface.
I've created a build task, following Visual Studio Test.
But now the Test-Task exit with code 1 and gives me a lot of
"System.IO.FileNotFoundException: Could not load file or assembly" errors.
And also "Warning: MSTestAdapter failed to discover tests in class ..."
All the DLLs are where they have to be, the new definition has the same directory structure like the old one, but the test-task says there are missing assemblys.
Any ideas?
Update:
No, I still have the same error messages:
Warning: Unable to load types from the test source 'J:\xyz-Tests.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Commons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyz_Processing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'xyzCommons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This should exactly be the issue mentioned in below article, please try following the workaround to fix it:
Running Coded UI Tests built using Visual Studio 2013 with Team Foundation Server 2015
Test execution is failing in this scenario because test execution
engine is not able to resolve the old version binaries while executing
tests in a 14.0 environment (TFS 2015).
So, you need to update the projects to reference the new versions of the assemblies (VS 2015 in this scenario) using the assembly bindings in the test projects config file.
As a workaround to this issue, add an ‘app.config’ file to your
solution (See how to add app.config
https://msdn.microsoft.com/en-in/library/ms184658.aspx) and update the
contents of the file with the shared on OneDrive . The updated
configuration files contain assembly redirects from version 12.0 to
14.0, which will make sure that the test agent machine is able to resolve the framework assemblies. Check-in the updated configuration
file into the source control repository and run the BDT scenario once
again. The tests should run fine this time. If the test execution
again throws an error complaining version mismatch for some other
assembly, add the assembly to the app.config file and retry.
You can also reference this article :
http://www.dotnetcatch.com/2015/10/01/tfs-2010-to-2015-upgrade-codedui-feature-test-builds/
I am using Bamboo [from Altassian] and it uses the devenv.com builder to build solution files. Currently, I seem to be getting a "false" error in my builds - that I've tried to solve by myself but just can't - so I thought I would ask.
Each build succeeds normally - without errors stemming from code - but seems to instead give this error
Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.
I've no idea why this is causing problems in the devenv.com environment and I can't figure out either how to "ignore" this error by some build command?
Try this ( from MSFT support )
Can you check if the dll is in the global assembly cache (open a VS 2010 command prompt
(Start | All Programs | Microsoft Visual Studio 10.0 | Visual Studio Tools))
Type in
Gacutil –l > list.txt
Notepad list.txt
Do you see an entry like
Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
If so, from the same command prompt, run fuslogvw, go to settings, select log bind failures to disk, select ok
Run your command line
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com /Build "Release|Mixed Platforms" "D:\Builds\19\Test VizXView\VizXView v1.8 Test Release Build - Weekly\Sources\VizXView v1.8\VizXView 1.8.sln"
Click on the refresh button in fuslogvw. Do we get any bind errors?
I had a similar issue related to running unit tests on a build server that was using devenv.exe (not devenv.com). I had a premium VS installed on the build server but I'd written the unit tests with ultimate (which 'has' load testing, even tho I'd not used it). I used fusion viewer to work out that the missing dll was LoadTest.dll which I copied from my laptop to the buildserver, I also removed references in my solution that were in version control to: *.vsmdi and *.testsettings (they're deprecated) and I removed from the build def a reference to a .testsettings file.
My guess would be that even though I wasn't running a load unit test the build agent was trying to load the LoadTest libs just in case. Hope that helps
edit ---
ok, my own problem here was that I've got both vs2010 and vs2013 on my laptop. When I added the first test project to my VS2010 solution, the project added actually has a dependency on the 2013 version of the UnitTestFramework.dll. My build server only has vs2010 on it so I got the missing assembly error. Switching the reference to the 2010 version fixed this.
I just installed Sharepoint 2010 stand-alone on Windows 7 and I'm trying to deploy a web part by simply selecting Build->Deploy. The web part doesn't contain anything; I just wanted to test if I can at least deploy an empty one.
Here's the output I get before Visual Studio crashes with "Visual Studio has encountered a problem and needs to close":
------ Deploy started: Project: SharePointProject3, Configuration:
Debug Any CPU ------ Active Deployment
Configuration: Default
Run Pre-Deployment Command: Skipping
deployment step because a
pre-deployment command is not
specified.
Recycle IIS Application Pool:
Skipping application pool recycle
because no matching package on the
server was found.
Retract Solution: Skipping package
retraction because no matching package
on the server was found. Add Solution:
This is the entry in the application log:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at EnvDTE.ProjectItem.get_Properties()
at Microsoft.VisualStudio.SharePoint.ProjectUtils.GetFullPath(EnvDTE.ProjectItem)
at Microsoft.VisualStudio.SharePoint.HierarchyItem.get_FullPath()
at Microsoft.VisualStudio.SharePoint.ProjectMember.get_FullPath()
at Microsoft.VisualStudio.SharePoint.ProjectExtensions.VSPackage.WebPartCommon.b__0(Microsoft.VisualStudio.SharePoint.ISharePointProjectItemFile)
at System.Linq.Enumerable+WhereEnumerableIterator1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at Microsoft.VisualStudio.SharePoint.ProjectExtensions.VSPackage.ProjectItemTypeProvider.HasAnyFileChanged(System.Collections.Generic.IEnumerable1)
Does anyone have an idea what the problem could be?
I ended up reinstalling VS2010. Now it works.