Error MSB4025. The project file could not be loaded. Data at the root level is invalid

7.6k views Asked by At

I have created a fresh NUnit project based on .net core 2.1.

When I run command dotnet test project1.dll in windows machine then its working fine but when I am trying to run same command in red hat linux machine (rhel 8), then it is giving error that "The project file could not be loaded. Data at the root level is invalid. Line 1, position 1". I look into solution in internet that you need to update your SDK but I want to use dotnet core 2.1 only and I could not found any command to install higher release version of dotnet core 2.1 in linux.

Please let me know if any prefer solution for this problem available. Below is my project file.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <IsPackable>false</IsPackable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
  </ItemGroup>
</Project>

Below information about SDK given by dotnet --info command on linux.

.NET Core SDK (reflecting any global.json):
 Version:   2.1.518
 Commit:    c9b5af2ec4

Runtime Environment:
 OS Name:     rhel
 OS Version:  8
 OS Platform: Linux
 RID:         rhel.8-x64
 Base Path:   /usr/lib64/dotnet/sdk/2.1.518/

Host (useful for support):
 Version: 2.1.22
 Commit:  23677d3ee7

.NET Core SDKs installed:
  2.1.518 [/usr/lib64/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.NETCore.App 2.1.22 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Note: I do not want to run test command using csproj file. I have requirements to run dotnet test command only using dlls.

2

There are 2 answers

2
rohan On

You might be looking for the dotnet vstest command: Documentation

You can use it like this: dotnet vstest project1.dll

0
Mohamed Mohsen On

Believe that clearing all Nuget packages then restoring the .sln will resolve it.

To clear all Nuget packages, go to Tools -> Options enter image description here

To restore the solution, right-click on the .sln then restore. enter image description here