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.


You might be looking for the
dotnet vstestcommand: DocumentationYou can use it like this:
dotnet vstest project1.dll