vstest: vstest.console.exe crashing on UWP unit test project with “Data at the root level is invalid.”
Trying to run a UWP unit test project using vstest.console.exe, I generate the appx package using MSBuild, and call:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform> ./vstest.console.exe C:\builds\droplocation\Uwp.UnitTesting\AppPackages\Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\wp.UnitTesting_1.0.0.0_x86_Debug.appx
But getting:
Microsoft (R) Test Execution Command Line Tool Version 15.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\builds\droplocation\RS.Uwp.UnitTesting\AppPackages\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.Build.Internal.XmlReaderExtension.GetXmlReader(StreamReader input, Encoding& encoding)
at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file)
at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
--- End of inner exception stack trace ---
at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass200_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache)
at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean isExplicitlyLoaded)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_Project()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_LayoutPath()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.Microsoft.VisualStudio.UwpTestHostRuntimeProvider.IDeployer.Deploy()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<LaunchHostAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<Microsoft-VisualStudio-TestPlatform-ObjectModel-Host-ITestRuntimeProvider-LaunchTestHostAsync>d__30.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
---> (Inner Exception #0) Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\builds\droplocation\RS.Uwp.UnitTesting\AppPackages\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.Build.Internal.XmlReaderExtension.GetXmlReader(StreamReader input, Encoding& encoding)
at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file)
at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
--- End of inner exception stack trace ---
at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass200_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache)
at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting)
at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean isExplicitlyLoaded)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_Project()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_LayoutPath()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.Microsoft.VisualStudio.UwpTestHostRuntimeProvider.IDeployer.Deploy()
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<LaunchHostAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<Microsoft-VisualStudio-TestPlatform-ObjectModel-Host-ITestRuntimeProvider-LaunchTestHostAsync>d__30.MoveNext()<---
Test Run Aborted.
When I change the vstest.console.exe
lcoation from:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform
to:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow
It works on my local machine with VS2017 Professional, but when called with the build agent on the remove build server, it’s still the same:
******************************************************************************
Starting: VsTest - UWP
******************************************************************************
==============================================================================
Task : Visual Studio Test
Description : Run tests with Visual Studio test runner
Version : 2.3.8
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)
==============================================================================
Run the tests locally using vstest.console.exe
========================================================
Test selector : Test assemblies
Test assemblies : C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx
Test filter criteria : null
Search folder : C:\agent\_work\2\s
Run settings file : C:\agent\_work\2\s
Run in parallel : false
Run in isolation : true
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Rerun failed tests: false
vstest.console.exe, specified location : C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow
========================================================
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @C:\agent\_work\_temp\635f6641-039f-11e8-b3d5-d35598e183b1.txt
Microsoft (R) Test Execution Command Line Tool Version 15.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
vstest.console.exe
"C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx"
/InIsolation
/logger:"trx"
/TestAdapterPath:"C:\agent\_work\2\s"
Starting test execution, please wait...
Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
What’s strange, when I try to run it manually on the build server, it crashes with following output:
PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow> ./vs
test.console.exe C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx
/InIsolation /Platform:x86
Microsoft (R) Test Execution Command Line Tool Version 15.0.27130.2020
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Unhandled Exception: System.Runtime.CallbackException: A user callback threw an exception. Check the exception stack an
d inner exception to determine the callback that failed. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: applicationName
at Microsoft.VisualStudio.TestPlatform.ObjectModel.ValidateArg.NotNull[T](T arg, String parameterName)
at Microsoft.VisualStudio.TestPlatform.Client.LocalCrashDumpUtilities.TryGetLocalCrashDumpPath(String applicationName
, String& crashDumpPath)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.TryGetLocalCrashDumpPath(String applicationNa
me, String& crashDumpPath)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.GetTestRunAbortedMessage(String executorProce
ssName, Int32 executorProcessId, Boolean hasExited, Boolean isRemoteExecution)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.TestExecutorServiceChannel_Reset(Object sende
r, EventArgs e)
at System.ServiceModel.Channels.CommunicationObject.OnClosed()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.CommunicationObject.OnClosed()
at System.ServiceModel.ServiceHostBase.OnClosed()
at System.ServiceModel.ServiceHost.OnClosed()
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at Microsoft.VisualStudio.TestPlatform.Client.UniversalTestExecutorProxy.Close()
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.StarPlatformSpecificTestExecution(IPlatformTe
stExecutorClient platformTestExecutorClient, ITestExecutorLauncher launcher, Architecture targetPlatform, FrameworkVersi
on targetFramework)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.Initialize_NoLock(Architecture targetPlatform
, FrameworkVersion targetFramework)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.EnsureInitialized(IDictionary`2 environmentVa
riables, TestExecutionContext context)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.<>c__DisplayClass18_0.<StartTestRun>b__0()
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.InvokeTestExecutorServiceAction(Action action
)
at Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.StartTestRun(IEnumerable`1 sources, TestExecu
tionContext executionContext, String runSettings, IDictionary`2 environmentVariables, String dataCollectionServiceUri, I
TestCaseLog testCaseLog, ITestRunLog testRunLog, IFrameworkHandleInternal frameworkHandle)
at Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.RocksteadyExecutionManager.StartTestRun(TestRunCriteria test
RunCriteria, Boolean inIsolation, DataCollectionParameters dataCollectionParameters, ITestRunEventsHandler runEventsHand
ler)
at Microsoft.VisualStudio.TestPlatform.Client.TestRunRequest.ExecuteAsync()
at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor.RunTests(IEnumerable`1 source
s, String packageFullName, String deviceInfo, Boolean isPhoneAppx, Boolean isUniversalTestAppx)
at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor.ExecuteAppContainerSources(Li
st`1 appContainerSources, String deviceInfo, Boolean isPhoneAppx)
at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor.Execute()
at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args)
at RockSteady.Program.Main(String[] args)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (6 by maintainers)
@mayankbansal018 , I was able to get it working again but I can’t recall what I did to get it running again 😁 .
I have tried vstest.console from both locations C:\Program Files\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe and C:\Program Files\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform with and without /framework:FrameworkUap10
All it does is launches the app and sits there forever when run from command line.
Only, when I open the project and Click Run-All then tests are discovered and start run correctly. It 's important for tests to run on Jenkins automatically. It’s a big roadblock.